package com.whut.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.whut.common.ReportCommonFunc;
import com.whut.enums.EquipReportWeightEnum;
import com.whut.mapper.*;
import com.whut.model.*;
import com.whut.service.EquipService;
import com.whut.service.NewFuzzyService;
import com.whut.service.ReportService;
import com.whut.utils.*;
import com.whut.v_dataMap.EquipAssessDataMap.*;
import com.whut.v_dataMap.comperhensiveInspectionDataMap.*;
import com.whut.v_dataMap.equipReportDataMap.*;
import com.whut.v_dataMap.equipReportDataMap.ProblemDescriptionListMap;
import com.whut.v_dataMap.equipReportDataMap.thirdPartyRiskReport.subAssess;
import com.whut.v_model.*;
import com.whut.v_vo.EquipRiskNumVO;
import com.whut.v_vo.comperInsReportBaseVO.PartOneHeadVO;
import com.whut.v_vo.comperInsReportBaseVO.ProblemFirstListVO;
import com.whut.v_vo.comperInsReportBaseVO.ProblemFourthListVO;
import com.whut.v_vo.comperInsReportBaseVO.ProblemLastListVO;
import com.whut.v_vo.equipReportBaseVO.*;
import org.apache.commons.beanutils.BeanMap;
import org.apache.commons.lang3.StringUtils;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartUtils;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.StandardChartTheme;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.CategoryLabelPositions;
import org.jfree.chart.labels.StandardCategoryItemLabelGenerator;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PiePlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.category.BarRenderer;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.data.general.DefaultPieDataset;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.awt.*;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.List;
import java.util.stream.Collectors;


@Service("reportService")
public class ReportServiceImpl implements ReportService {
    @Resource
    private ContracttaskprojectMapper contracttaskprojectMapper;
    @Resource
    private ContracttaskacceptMapper contracttaskacceptMapper;
    @Resource
    private ProblemCollectDetailMapper problemCollectDetailMapper;
    @Resource
    private PrefixsystemMapper prefixsystemMapper;
    @Resource
    private NewprefixsystemMapper newprefixsystemMapper;
    @Resource
    private ContractchecktaskMapper contractchecktaskMapper;
    @Resource
    private GroupMemberDetailMapper groupMemberDetailMapper;
    @Resource
    private ContractinfoMapper contractinfoMapper;
    @Resource
    private UncheckeditemsMapper uncheckeditemsMapper;
    @Resource
    private AllpointsaveMapper allpointsaveMapper;
    @Resource
    private PointlimitMapper pointlimitMapper;
    @Resource
    private SummaryMapper summaryMapper;
    @Resource
    private EquipinfoMapper equipinfoMapper;
    @Resource
    private FuzzyresultMapper fuzzyresultMapper;
    @Resource
    private MeasuretablerecordMapper measuretablerecordMapper;
    @Resource
    private EditableweightpsMapper editableweightpsMapper;
    @Resource
    private MachineinfoMapper machineinfoMapper;
    @Resource
    private NoproblemitemMapper noproblemitemMapper;
    @Resource
    private NewproblemdescriptionMapper newproblemdescriptionMapper;
    @Resource
    private EquipscoreMapper equipscoreMapper;
    @Resource
    private NewFuzzyService newFuzzyService;
    @Resource
    private EquipService equipService;
    @Resource
    private NewProblemCollectDetailMapper newProblemCollectDetailMapper;
    @Resource
    private UrlProperties urlProperties;
    @Resource
    private Profiles profiles;

    @Override
    public Object getAllCheckInfoForReport(String client, String task, String check, String startTime, String endTime) {
        List<CheckAndProject> list = new ArrayList<>();
        JSONArray jsonArray1 = JSONArray.parseArray(client);
        int contractId = jsonArray1.getIntValue(0);
        JSONArray jsonArray2 = JSONArray.parseArray(task);
        List<Integer> list2 = new ArrayList<>();
        for (int i = 0; i < jsonArray2.size(); i++) {
            list2.add(jsonArray2.getIntValue(i));
        }
        JSONArray jsonArray3 = JSONArray.parseArray(check);
        List<Integer> list3 = new ArrayList<>();
        for (int j = 0; j < jsonArray3.size(); j++) {
            list3.add(jsonArray3.getIntValue(j));
        }
        if (task.equals("[]") && check.equals("[]")) {
            list = contracttaskprojectMapper.getAllProjectForReportOnlyByClientAndTime(contractId, startTime, endTime);
        } else if (!task.equals("[]") && check.equals("[]")) {
            list = contracttaskprojectMapper.getAllProjectForReportOnlyByClientAndTaskAndTime(contractId, startTime, endTime, list2);
        } else if (!task.equals("[]") && !check.equals("[]")) {
            list = contracttaskprojectMapper.getAllProjectForReportOnlyByClientAndTaskAndAndCheckTime(contractId, startTime, endTime, list2, list3);
        }
        return list;
    }

    @Override
    public String getSecurityReport(String client, String check, String checkInfo) throws UnsupportedEncodingException {
        StandardChartTheme standardChartTheme = new StandardChartTheme("CN");
        //设置标题字体
        standardChartTheme.setExtraLargeFont(new Font("隶书", Font.BOLD, 20));
        //设置图例的字体
        standardChartTheme.setRegularFont(new Font("宋书", Font.PLAIN, 15));
        //设置轴向的字体
        standardChartTheme.setLargeFont(new Font("宋书", Font.PLAIN, 15));
        ChartFactory.setChartTheme(standardChartTheme);
        //应用主题样式
        DecimalFormat df = new DecimalFormat("0.00");
        Map<String, Object> dataMap = new HashMap<>();
        Date date = new Date();
        DateFormat d1 = new SimpleDateFormat("yyyyMMddhhmmss");
        DateFormat d2 = new SimpleDateFormat("yyyy");
        DateFormat d3 = new SimpleDateFormat("MM");
        String month = d3.format(date);
        String year = d2.format(date);
        String fileName = d1.format(date);
        dataMap.put("month", month);
        dataMap.put("year", year);
        JSONArray jsonArray = JSONArray.parseArray(checkInfo);
        JSONArray jsonArray1 = JSONArray.parseArray(client);
        int contractId = jsonArray1.getIntValue(0);
        dataMap.put("client", contractinfoMapper.getClientByContractId(contractId));
        JSONArray jsonArray2 = JSONArray.parseArray(check);
        List<Integer> list2 = new ArrayList<>();
        for (int j = 0; j < jsonArray2.size(); j++) {
            list2.add(jsonArray2.getIntValue(j));
        }
        List<CheckAndProject> rankPointList = contracttaskprojectMapper.getCheckAndPointOrderByPoint(list2);
        dataMap.put("projectNum", jsonArray2.size());
        List<Integer> allCheckItemsIdList = problemCollectDetailMapper.getAllFourthIdByCheckList(list2, 1);
        List<String> allCheckItemsNameInfoList = new ArrayList<>();
        for (int i = 0; i < allCheckItemsIdList.size(); i++) {
            allCheckItemsNameInfoList.add(prefixsystemMapper.getName4ByName4Id(allCheckItemsIdList.get(i)));
        }
        String allCheckItems = StringOperate.listToString(allCheckItemsNameInfoList, "、");
        dataMap.put("allCheckItems", allCheckItems);
        //一、检查项目排名部分
        List<String> unitTypeList = new ArrayList<>();
        unitTypeList.add("sgUnit");
        unitTypeList.add("jlUnit");
        unitTypeList.add("jsUnit");
        List<Object> unitRankList = new ArrayList<>();
        for (int i = 0; i < unitTypeList.size(); i++) {
            Map<String, Object> unitRankMap = new HashMap<>();
            List<Object> unitRankInnerList = new ArrayList<>();
            switch (unitTypeList.get(i)) {
                case "sgUnit":
                    unitRankMap.put("unitType", "施工单位");
                    break;
                case "jlUnit":
                    unitRankMap.put("unitType", "监理单位");
                    break;
                case "jsUnit":
                    unitRankMap.put("unitType", "建设单位");
                    break;
                default:
            }
            for (int j = 0; j < rankPointList.size(); j++) {
                Map<String, Object> unitRankInnerMap = new HashMap<>();
                unitRankInnerMap.put("rank", j + 1);
                unitRankInnerMap.put("projectName", rankPointList.get(j).getProjectName());
                switch (unitTypeList.get(i)) {
                    case "sgUnit":
                        unitRankInnerMap.put("unit", rankPointList.get(j).getSgUnit());
                        break;
                    case "jlUnit":
                        unitRankInnerMap.put("unit", rankPointList.get(j).getJlUnit());
                        break;
                    case "jsUnit":
                        unitRankInnerMap.put("unit", rankPointList.get(j).getJsUnit());
                        break;
                    default:
                }
                unitRankInnerMap.put("point", rankPointList.get(j).getTotalPoint() == null ? "0" : df.format(Double.parseDouble(rankPointList.get(j).getTotalPoint())));
                unitRankInnerMap.put("riskPoint", rankPointList.get(j).getLatestRiskLevel() == null ? "" : rankPointList.get(j).getLatestRiskLevel());
                if (rankPointList.get(j).getTotalPoint() == null) {
                    unitRankInnerMap.put("overAllMerit", "不合格");
                } else {
                    if (Double.parseDouble(rankPointList.get(j).getTotalPoint()) >= 70) {
                        unitRankInnerMap.put("overAllMerit", "合格");
                    } else {
                        unitRankInnerMap.put("overAllMerit", "不合格");
                    }
                }
                unitRankInnerList.add(unitRankInnerMap);
            }
            unitRankMap.put("unitRankInnerList", unitRankInnerList);
            unitRankList.add(unitRankMap);
        }
        dataMap.put("unitRankList", unitRankList);

        //二、安全隐患分布情况(一)隐患等级分布比例
        TimesStat timesStat = problemCollectDetailMapper.getAllSecurityRiskPoint(list2, 1);
        int allProblemNum = problemCollectDetailMapper.getAllSecurityProblemNum(list2, 1);
        dataMap.put("level4", timesStat.getCount4());
        dataMap.put("level3", timesStat.getCount3());
        dataMap.put("level2", timesStat.getCount2());
        dataMap.put("level01", timesStat.getCount0() + timesStat.getCount1());
        dataMap.put("allProblemNum", allProblemNum);
        dataMap.put("level4Percent", pointsCalculate.caculateToPercent(timesStat.getCount4(), allProblemNum));
        dataMap.put("level3Percent", pointsCalculate.caculateToPercent(timesStat.getCount3(), allProblemNum));
        dataMap.put("level2Percent", pointsCalculate.caculateToPercent(timesStat.getCount2(), allProblemNum));
        dataMap.put("level01Percent", pointsCalculate.caculateToPercent(timesStat.getCount0() + timesStat.getCount1(), allProblemNum));
        DefaultPieDataset datasetRiskPie = new DefaultPieDataset();
        datasetRiskPie.setValue("提醒和特征值1" + ":" + pointsCalculate.caculateToPercent(timesStat.getCount0() + timesStat.getCount1(), allProblemNum), new Double(timesStat.getCount0() + timesStat.getCount1()));
        datasetRiskPie.setValue("特征值2" + ":" + pointsCalculate.caculateToPercent(timesStat.getCount2(), allProblemNum), new Double(timesStat.getCount2()));
        datasetRiskPie.setValue("特征值3" + ":" + pointsCalculate.caculateToPercent(timesStat.getCount3(), allProblemNum), new Double(timesStat.getCount3()));
        datasetRiskPie.setValue("特征值4" + ":" + pointsCalculate.caculateToPercent(timesStat.getCount4(), allProblemNum), new Double(timesStat.getCount4()));
        try {
            JFreeChart chart = ChartFactory.createPieChart("隐患分布饼图", datasetRiskPie, true, true, false);
            final PiePlot plot = (PiePlot) chart.getPlot();
            plot.setStartAngle(0);
            plot.setForegroundAlpha(0.90f);
            plot.setInteriorGap(0.02);
            chart.getLegend().setVisible(false);
            plot.setSectionPaint("提醒和特征值1" + ":" + pointsCalculate.caculateToPercent(timesStat.getCount0() + timesStat.getCount1(), allProblemNum), new Color(49, 95, 232));
            plot.setSectionPaint("特征值2" + ":" + pointsCalculate.caculateToPercent(timesStat.getCount2(), allProblemNum), new Color(232, 232, 49));
            plot.setSectionPaint("特征值3" + ":" + pointsCalculate.caculateToPercent(timesStat.getCount3(), allProblemNum), new Color(240, 117, 60));
            plot.setSectionPaint("特征值4" + ":" + pointsCalculate.caculateToPercent(timesStat.getCount4(), allProblemNum), new Color(232, 36, 18));
            File pieChart = new File("D:\\whutServer\\generatedCharts\\" + fileName + "securityRiskPieChart.png");
//            File pieChart = new File("E:\\tencent_File\\1296928795\\FileRecv\\yirui\\" + fileName + "securityRiskPieChart.png");
            ChartUtils.saveChartAsPNG(pieChart, chart, 718, 468);
        } catch (Exception e) {
            e.printStackTrace();
        }
//        dataMap.put("pic1", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\yirui\\" + fileName + "securityRiskPieChart.png"));
        dataMap.put("pic1", MDoc.getImageStr("D:\\whutServer\\generatedCharts\\" + fileName + "securityRiskPieChart.png"));
        //（二）安全隐患分布比例
        List<Object> problemNumList = new ArrayList<>();
        DefaultPieDataset datasetPie = new DefaultPieDataset();
        DefaultCategoryDataset datasetBar = new DefaultCategoryDataset();
        final String Bar = "各检查分项";
        for (int i = 0; i < allCheckItemsIdList.size(); i++) {
            Map<String, Object> problemNumMap = new HashMap<>();
            problemNumMap.put("no", i + 1);
            problemNumMap.put("pName4", prefixsystemMapper.getName4ByName4Id(allCheckItemsIdList.get(i)));
            int innerProblemNum = problemCollectDetailMapper.getSecurityProblemNum(list2, allCheckItemsIdList.get(i));
            problemNumMap.put("problemNum", innerProblemNum);
            problemNumMap.put("percent", pointsCalculate.caculateToPercent(innerProblemNum, allProblemNum));
            datasetPie.setValue(prefixsystemMapper.getName4ByName4Id(allCheckItemsIdList.get(i)) + ":" + pointsCalculate.caculateToPercent(innerProblemNum, allProblemNum), new Double(innerProblemNum));
            datasetBar.addValue(innerProblemNum, Bar, prefixsystemMapper.getName4ByName4Id(allCheckItemsIdList.get(i)));
            problemNumList.add(problemNumMap);
        }
        dataMap.put("problemNumList", problemNumList);
        try {
            JFreeChart chart = ChartFactory.createPieChart("现场施工问题分布饼图", datasetPie, true, true, false);
            final PiePlot plot = (PiePlot) chart.getPlot();
            plot.setStartAngle(270);
            plot.setForegroundAlpha(0.90f);
            plot.setInteriorGap(0.02);
            chart.getLegend().setVisible(false);
            File pieChart = new File("D:\\whutServer\\generatedCharts\\" + fileName + "securityPieChart.png");
//            File pieChart = new File("E:\\tencent_File\\1296928795\\FileRecv\\yirui\\" + fileName + "securityPieChart.png");
            ChartUtils.saveChartAsPNG(pieChart, chart, 718, 468);
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            JFreeChart barChart = ChartFactory.createBarChart("现场施工问题分布直方图",
                    "",
                    "数量",
                    datasetBar,
                    PlotOrientation.VERTICAL,
                    true, true, false);
            CategoryPlot plot = (CategoryPlot) barChart.getPlot();
            plot.getRenderer().setSeriesPaint(0, new Color(5, 87, 232));
            BarRenderer barRenderer = (BarRenderer) plot.getRenderer();
            barRenderer.setDefaultItemLabelGenerator(new StandardCategoryItemLabelGenerator());
            barRenderer.setDefaultItemLabelsVisible(true);
            barRenderer.setItemLabelAnchorOffset(-20D);
            barRenderer.setMaximumBarWidth(0.2);
            CategoryAxis categoryAxis = plot.getDomainAxis();
            categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
            File barChartFile = new File("D:\\whutServer\\generatedCharts\\" + fileName + "securityBarChart.png");
//            File barChartFile = new File("E:\\tencent_File\\1296928795\\FileRecv\\yirui\\" + fileName + "securityBarChart.png");
            ChartUtils.saveChartAsPNG(barChartFile, barChart, 718, 468);
        } catch (Exception e) {
            e.printStackTrace();
        }
        dataMap.put("pic2", MDoc.getImageStr("D:\\whutServer\\generatedCharts\\" + fileName + "securityPieChart.png"));
        dataMap.put("pic3", MDoc.getImageStr("D:\\whutServer\\generatedCharts\\" + fileName + "securityBarChart.png"));
//        dataMap.put("pic2", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\yirui\\" + fileName + "securityPieChart.png"));
//        dataMap.put("pic3", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\yirui\\" + fileName + "securityBarChart.png"));
        //三、安全隐患汇总分析
        List<Object> part3List = new ArrayList<>();
        for (int i = 0; i < allCheckItemsIdList.size(); i++) {
            List<Object> part3InnerList = new ArrayList<>();
            Map<String, Object> part3Map = new HashMap<>();
            part3Map.put("pName4", prefixsystemMapper.getName4ByName4Id(allCheckItemsIdList.get(i)));
            List<Integer> part3ProjectNumList = problemCollectDetailMapper.getSecurityPart3ProjectNum(list2, allCheckItemsIdList.get(i));
            int level4Num = 0;
            int level3Num = 0;
            int level2Num = 0;
            int level01Num = 0;
            part3Map.put("projectNum", part3ProjectNumList.size());
            for (int y = 0; y < part3ProjectNumList.size(); y++) {
                List<ProblemCollectDetail> part3RiskProjectNumList = problemCollectDetailMapper.getAllProblemCollectInfoByCheckId(part3ProjectNumList.get(y));
                String maxRisk = pointsCalculate.getMaxRiskPoint(part3RiskProjectNumList);
                switch (maxRisk) {
                    case "提醒":
                        level01Num++;
                        break;
                    case "1":
                        level01Num++;
                        break;
                    case "2":
                        level2Num++;
                        break;
                    case "3":
                        level3Num++;
                        break;
                    case "4":
                        level4Num++;
                        break;
                    default:
                }
            }
            part3Map.put("level4Num", level4Num);
            part3Map.put("level3Num", level3Num);
            part3Map.put("level2Num", level2Num);
            part3Map.put("level01Num", level01Num);
            part3Map.put("problemNum", problemCollectDetailMapper.getSecurityProblemNum(list2, allCheckItemsIdList.get(i)));
            TimesStat timesStat1 = problemCollectDetailMapper.getSecurityRiskPoint(list2, allCheckItemsIdList.get(i));
            part3Map.put("level4", timesStat1.getCount4());
            part3Map.put("level3", timesStat1.getCount3());
            part3Map.put("level2", timesStat1.getCount2());
            part3Map.put("level01", timesStat1.getCount0() + timesStat1.getCount1());
            part3Map.put("level4Percent", pointsCalculate.caculateToPercent(timesStat1.getCount4(), problemCollectDetailMapper.getSecurityProblemNum(list2, allCheckItemsIdList.get(i))));
            part3Map.put("level3Percent", pointsCalculate.caculateToPercent(timesStat1.getCount3(), problemCollectDetailMapper.getSecurityProblemNum(list2, allCheckItemsIdList.get(i))));
            part3Map.put("level2Percent", pointsCalculate.caculateToPercent(timesStat1.getCount2(), problemCollectDetailMapper.getSecurityProblemNum(list2, allCheckItemsIdList.get(i))));
            part3Map.put("level01Percent", pointsCalculate.caculateToPercent(timesStat1.getCount0() + timesStat1.getCount1(), problemCollectDetailMapper.getSecurityProblemNum(list2, allCheckItemsIdList.get(i))));
            DefaultPieDataset datasetInnerRiskPie = new DefaultPieDataset();
            datasetInnerRiskPie.setValue("提醒和特征值1" + ":" + pointsCalculate.caculateToPercent(timesStat1.getCount0() + timesStat1.getCount1(), problemCollectDetailMapper.getSecurityProblemNum(list2, allCheckItemsIdList.get(i))), new Double(timesStat1.getCount0() + timesStat1.getCount1()));
            datasetInnerRiskPie.setValue("特征值2" + ":" + pointsCalculate.caculateToPercent(timesStat1.getCount2(), problemCollectDetailMapper.getSecurityProblemNum(list2, allCheckItemsIdList.get(i))), new Double(timesStat1.getCount2()));
            datasetInnerRiskPie.setValue("特征值3" + ":" + pointsCalculate.caculateToPercent(timesStat1.getCount3(), problemCollectDetailMapper.getSecurityProblemNum(list2, allCheckItemsIdList.get(i))), new Double(timesStat1.getCount3()));
            datasetInnerRiskPie.setValue("特征值4" + ":" + pointsCalculate.caculateToPercent(timesStat1.getCount4(), problemCollectDetailMapper.getSecurityProblemNum(list2, allCheckItemsIdList.get(i))), new Double(timesStat1.getCount4()));
            try {
                JFreeChart chart = ChartFactory.createPieChart(prefixsystemMapper.getName4ByName4Id(allCheckItemsIdList.get(i)) + "隐患分布饼图", datasetInnerRiskPie, true, true, false);
                final PiePlot plot = (PiePlot) chart.getPlot();
                plot.setStartAngle(0);
                plot.setForegroundAlpha(0.90f);
                plot.setInteriorGap(0.02);
                chart.getLegend().setVisible(false);
                plot.setSectionPaint("提醒和特征值1" + ":" + pointsCalculate.caculateToPercent(timesStat1.getCount0() + timesStat1.getCount1(), problemCollectDetailMapper.getSecurityProblemNum(list2, allCheckItemsIdList.get(i))), new Color(49, 95, 232));
                plot.setSectionPaint("特征值2" + ":" + pointsCalculate.caculateToPercent(timesStat1.getCount2(), problemCollectDetailMapper.getSecurityProblemNum(list2, allCheckItemsIdList.get(i))), new Color(232, 232, 49));
                plot.setSectionPaint("特征值3" + ":" + pointsCalculate.caculateToPercent(timesStat1.getCount3(), problemCollectDetailMapper.getSecurityProblemNum(list2, allCheckItemsIdList.get(i))), new Color(240, 117, 60));
                plot.setSectionPaint("特征值4" + ":" + pointsCalculate.caculateToPercent(timesStat1.getCount4(), problemCollectDetailMapper.getSecurityProblemNum(list2, allCheckItemsIdList.get(i))), new Color(232, 36, 18));
//                File pieChart = new File("E:\\tencent_File\\1296928795\\FileRecv\\yirui\\" + fileName +i+ "securityInnerRiskPieChart.png");
                File pieChart = new File("D:\\whutServer\\generatedCharts\\" + fileName + i + "securityInnerRiskPieChart.png");
                ChartUtils.saveChartAsPNG(pieChart, chart, 718, 468);
            } catch (Exception e) {
                e.printStackTrace();
            }
            part3Map.put("pic1", MDoc.getImageStr("D:\\whutServer\\generatedCharts\\" + fileName + i + "securityInnerRiskPieChart.png"));
//            part3Map.put("pic1",MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\yirui\\" + fileName +i+ "securityInnerRiskPieChart.png"));

            DefaultCategoryDataset datasetRiskBar = new DefaultCategoryDataset();
            final String flag1 = "提醒和特征值1";
            final String flag2 = "特征值2";
            final String flag3 = "特征值3";
            final String flag4 = "特征值4";
            final String riskBar = "特征值情况统计";
            datasetRiskBar.addValue(timesStat1.getCount0() + timesStat1.getCount1(), flag1, riskBar);
            datasetRiskBar.addValue(timesStat1.getCount2(), flag2, riskBar);
            datasetRiskBar.addValue(timesStat1.getCount3(), flag3, riskBar);
            datasetRiskBar.addValue(timesStat1.getCount4(), flag4, riskBar);
            try {
                JFreeChart barChart = ChartFactory.createBarChart("隐患分布直方图",
                        "",
                        "数量",
                        datasetRiskBar,
                        PlotOrientation.VERTICAL,
                        true, true, false);
                CategoryPlot plot = (CategoryPlot) barChart.getPlot();
                plot.getRenderer().setSeriesPaint(0, new Color(49, 95, 232));
                plot.getRenderer().setSeriesPaint(1, new Color(232, 232, 49));
                plot.getRenderer().setSeriesPaint(2, new Color(240, 117, 60));
                plot.getRenderer().setSeriesPaint(3, new Color(232, 36, 18));
                BarRenderer barRenderer = (BarRenderer) plot.getRenderer();
                barRenderer.setDefaultItemLabelGenerator(new StandardCategoryItemLabelGenerator());
                barRenderer.setDefaultItemLabelsVisible(true);
                barRenderer.setItemLabelAnchorOffset(-20D);
                File barChartFile = new File("D:\\whutServer\\generatedCharts\\" + fileName + i + "securityRiskBarChart.png");
//                File barChartFile = new File("E:\\tencent_File\\1296928795\\FileRecv\\yirui\\" + fileName +i+ "securityRiskBarChart.png");

                ChartUtils.saveChartAsPNG(barChartFile, barChart, 718, 468);
            } catch (Exception e) {
                e.printStackTrace();
            }
            part3Map.put("pic2", MDoc.getImageStr("D:\\whutServer\\generatedCharts\\" + fileName + i + "securityRiskBarChart.png"));
//            part3Map.put("pic2",MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\yirui\\" + fileName +i+ "securityRiskBarChart.png"));

            List<Integer> part3InnerSixthInfoList = problemCollectDetailMapper.getSecurityInnerSixthId(list2, allCheckItemsIdList.get(i));
            List<String> part3InnerSixthNameList = new ArrayList<>();
            for (int k = 0; k < part3InnerSixthInfoList.size(); k++) {
                part3InnerSixthNameList.add(prefixsystemMapper.getName4ByName4Id(part3InnerSixthInfoList.get(k)));
            }
            part3Map.put("allpName6", StringOperate.listToString(part3InnerSixthNameList, "、"));
            DefaultPieDataset datasetInnerPie = new DefaultPieDataset();
            DefaultCategoryDataset datasetInnerBar = new DefaultCategoryDataset();
            for (int j = 0; j < part3InnerSixthInfoList.size(); j++) {
                Map<String, Object> part3InnerMap = new HashMap<>();
                part3InnerMap.put("no", j + 1);
                part3InnerMap.put("pName6", prefixsystemMapper.getName4ByName4Id(part3InnerSixthInfoList.get(j)));
                int part3InnerProblemNum = problemCollectDetailMapper.getPart3InnerProblemNum(list2, part3InnerSixthInfoList.get(j));
                part3InnerMap.put("problemNum", part3InnerProblemNum);
                part3InnerMap.put("percent", pointsCalculate.caculateToPercent(part3InnerProblemNum, problemCollectDetailMapper.getSecurityProblemNum(list2, allCheckItemsIdList.get(i))));
                List<Integer> part3InnerProjectList = problemCollectDetailMapper.getPart3InnerProject(list2, part3InnerSixthInfoList.get(j));
                part3InnerMap.put("projectNum", part3InnerProjectList.size());
                datasetInnerPie.setValue(prefixsystemMapper.getName4ByName4Id(part3InnerSixthInfoList.get(j)) + pointsCalculate.caculateToPercent(part3InnerProblemNum, problemCollectDetailMapper.getSecurityProblemNum(list2, allCheckItemsIdList.get(i))), new Double(part3InnerProblemNum));
                datasetInnerBar.addValue(part3InnerProblemNum, Bar, prefixsystemMapper.getName4ByName4Id(part3InnerSixthInfoList.get(j)));
                List<ProblemCollectDetail> part3InnerDescriptionList = problemCollectDetailMapper.getPart3InnerDescriptionAllInfo(list2, part3InnerSixthInfoList.get(j));
                List<String> part3InnerDescriptionAllList = new ArrayList<>();
                for (int m = 0; m < part3InnerDescriptionList.size(); m++) {
                    if (part3InnerDescriptionList.get(m).getIsRemark().equals("N")) {
                        part3InnerDescriptionAllList.add(part3InnerDescriptionList.get(m).getProblemDescription());
                    } else if (part3InnerDescriptionList.get(m).getIsRemark().equals("Y")) {
                        part3InnerDescriptionAllList.add(part3InnerDescriptionList.get(m).getRemark());
                    }
                }
                part3InnerMap.put("allProblemDescription", StringOperate.listToString(part3InnerDescriptionAllList, "、"));
               /* List<Object> picList = new ArrayList<>();
                for(int u=0;u<part3InnerDescriptionList.size();u++)
                {
                    String picPath=part3InnerDescriptionList.get(u).getPicPath();
                    String picName=part3InnerDescriptionList.get(u).getPicName();
                    JSONArray ja = JSONArray.parseArray(picName);
                    if (ja.size() == 0) {
                        //String s = MDoc.getImageStr("C:\\Users\\96500\\Desktop\\20190329183836002.png");
                        String s = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                        picList.add(s);
                    } else {
                        for (int o = 0; o < ja.size(); o++) {
                            String s = MDoc.getImageStr(picPath + ja.getString(o));
                            //String s = MDoc.getImageStr("C:\\Users\\96500\\Desktop\\20190329183836002.png");
                            picList.add(s);
                        }
                    }
                }
                part3InnerMap.put("picList",picList);*/
                part3InnerList.add(part3InnerMap);
            }
            try {
                JFreeChart chart = ChartFactory.createPieChart("现场施工问题分布饼图", datasetInnerPie, true, true, false);
                final PiePlot plot = (PiePlot) chart.getPlot();
                plot.setStartAngle(270);
                plot.setForegroundAlpha(0.90f);
                plot.setInteriorGap(0.02);
                chart.getLegend().setVisible(false);
                File pieChart = new File("D:\\whutServer\\generatedCharts\\" + fileName + i + "securityPieInnerChart.png");
//                File pieChart = new File("E:\\tencent_File\\1296928795\\FileRecv\\yirui\\" + fileName +i+ "securityPieInnerChart.png");

                ChartUtils.saveChartAsPNG(pieChart, chart, 718, 468);
            } catch (Exception e) {
                e.printStackTrace();
            }
            try {
                JFreeChart barChart = ChartFactory.createBarChart("现场施工问题分布直方图",
                        "",
                        "数量",
                        datasetInnerBar,
                        PlotOrientation.VERTICAL,
                        true, true, false);
                CategoryPlot plot = (CategoryPlot) barChart.getPlot();
                plot.getRenderer().setSeriesPaint(0, new Color(5, 87, 232));
                BarRenderer barRenderer = (BarRenderer) plot.getRenderer();
                barRenderer.setDefaultItemLabelGenerator(new StandardCategoryItemLabelGenerator());
                barRenderer.setDefaultItemLabelsVisible(true);
                barRenderer.setItemLabelAnchorOffset(-20D);
                barRenderer.setMaximumBarWidth(0.2);
                CategoryAxis categoryAxis = plot.getDomainAxis();
                categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
                File barChartFile = new File("D:\\whutServer\\generatedCharts\\" + fileName + i + "securityBarInnerChart.png");
//                File barChartFile = new File("E:\\tencent_File\\1296928795\\FileRecv\\yirui\\" + fileName +i+ "securityBarInnerChart.png");

                ChartUtils.saveChartAsPNG(barChartFile, barChart, 718, 468);
            } catch (Exception e) {
                e.printStackTrace();
            }
            part3Map.put("pic3", MDoc.getImageStr("D:\\whutServer\\generatedCharts\\" + fileName + i + "securityPieInnerChart.png"));
            part3Map.put("pic4", MDoc.getImageStr("D:\\whutServer\\generatedCharts\\" + fileName + i + "securityBarInnerChart.png"));
//            part3Map.put("pic3", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\yirui\\" + fileName +i+ "securityPieInnerChart.png"));
//            part3Map.put("pic4", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\yirui\\" + fileName +i+ "securityBarInnerChart.png"));

            part3Map.put("part3InnerList", part3InnerList);
            part3List.add(part3Map);
        }
        dataMap.put("part3List", part3List);
        /*MDoc mdoc = new MDoc();
        String path = FileUtil.getServerFolderPath();
        File f1 = new File(path, "doc");
        if (!f1.exists()) {
            f1.mkdirs();
        }
        mdoc.createDoc(dataMap, path + "\\doc\\" + "安全总报"+fileName + ".doc", "ftl\\securityReport2.0.ftl");
        MDoc.docToDocx("D:\\whutServer\\apache-tomcat-8.5.41\\webapps\\ROOT\\doc\\" + "安全总报"+fileName + ".doc", "D:\\whutServer\\apache-tomcat-8.5.41\\webapps\\ROOT\\doc\\" + "安全总报"+fileName +".doc");
        String result = urlProperties.getAddress()+"/doc/" + "安全总报"+fileName + ".doc";*/
        return generateReport(dataMap, "安全总报", "securityReport2.0");
    }

    @Override
    public String rectificationNoticeCreate(int checkId) throws UnsupportedEncodingException {
        HashMap<String, Object> dataMap = new HashMap<>();
        List<ContractCheckTask> getBaseData = contractchecktaskMapper.getBaseData(checkId);
        //System.out.println("getBaseData:"+getBaseData);
        String finishTime = getBaseData.get(0).getFinishTime();
        String year = finishTime.substring(0, 4);
        String month = finishTime.substring(5, 7);
        String date = finishTime.substring(8, 10);
        /*Date d = new SimpleDateFormat("yyyy-MM-dd").parse(finishTime);
        SimpleDateFormat Dyear = new SimpleDateFormat("yyyy");
        SimpleDateFormat Dmonth = new SimpleDateFormat("MM");
        SimpleDateFormat Ddate = new SimpleDateFormat("dd");
        String year = Dyear.format(d);
        String month = Dmonth.format(d);
        String date = Ddate.format(d);*/
        dataMap.put("finishMonth", month + "月份");
        dataMap.put("finishTime", year + "年" + month + "月" + date + "日");
        dataMap.put("projectName", getBaseData.get(0).getProjectName());
        dataMap.put("xfUnit", "");
        dataMap.put("receiveUnit", "");
        dataMap.put("ruLeader", "");
        /*List<GroupMemberDetail> getGroupMem = groupMemberDetailMapper.getGroupMemByCheckID(checkId);*/

        //System.out.println("getGroupMem:" + getGroupMem);

        /*int temp = 0;
        String str = "";
        for (GroupMemberDetail gmd: getGroupMem) {
            temp++;
            if(!gmd.getUserName().equals("")){
                str += gmd.getUserName()+",";
                if(getGroupMem.size() == temp){
                    str += gmd.getUserName();
                }
            }
        }
        dataMap.put("checkMember", str.toString());*/

        //forthlist + sevenlist循环
        //String pName4 = "";
        List<String> pName4 = new ArrayList<>();
        List<ProblemCollectDetail> forthLevel = problemCollectDetailMapper.getForthLevelByCheckId(checkId);

        for (ProblemCollectDetail pcd : forthLevel) {
            if (!pName4.contains(pcd.getpName4())) {
                pName4.add(pcd.getpName4());
            }
        }
        //tem.out.println("pName4:"+pName4);


        List<Object> forthLevelList = new ArrayList<>();
        for (int i = 0; i < pName4.size(); i++) {
            String s = "";
            String p = "";
            String storeS = "";
            String storeP = "";
            HashMap<String, Object> forthLevelMap = new HashMap<>();
            if (!pName4.get(i).equals("文明施工")) {
                List<ProblemCollectDetail> sevenLevel = problemCollectDetailMapper.getProDescByCheckIdAndpName4UnderSecur(checkId, pName4.get(i));
                List<Object> seventhLevelList = new ArrayList<>();
                List<Object> flPicList = new ArrayList<>();
                forthLevelMap.put("forthName", pName4.get(i));
                //System.out.println("pName4:"+pName4.get(i));

                List<String> picNameList = new ArrayList<>();
                int temp1 = 0;
                List<Integer> jaSize = new ArrayList<>();
                for (ProblemCollectDetail pcd1 : sevenLevel) {
                    temp1++;
                    HashMap<String, Object> seventhLevelMap = new HashMap<>();
                    //System.out.println("sevenLevel.size:" + sevenLevel.size());

                    if (!pcd1.getRemark().equals("")) {
                        seventhLevelMap.put("problemDescription", pcd1.getCheckPart() + ":" + pcd1.getRemark());
                        seventhLevelList.add(seventhLevelMap);
                        // System.out.println("seventhLevelList:" + seventhLevelList);
                    } else {
                        seventhLevelMap.put("problemDescription", pcd1.getCheckPart() + ":" + pcd1.getProblemDescription());
                        seventhLevelList.add(seventhLevelMap);
                        // System.out.println("seventhLevelList:" + seventhLevelList);
                    }

                    //获取picName(!pName.equals("文明施工"))
                    String picName = pcd1.getPicName();
                    JSONArray ja = JSONArray.parseArray(picName);
                    jaSize.add(ja.size());
                    //图片文字循环
                    for (int u = 0; u < ja.size(); u++) {
                        //  System.out.println("u:"+u);
                        //  System.out.println("storeS:"+storeS);
                        // System.out.println("storeP:"+storeP);
                        HashMap<String, Object> flPicMap = new HashMap<>();
                        if (!pcd1.getRemark().equals("")) {
                            if (!storeS.equals("") && !storeP.equals("")) {
                                if (u % 2 != 0) {
                                    if (pcd1.getPicPath().equals("")) {
                                        //s = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                                        s = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                                    } else {
                                        s = MDoc.getImageStr(pcd1.getPicPath() + ja.get(u));
                                        //s = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\12.png");
                                    }
                                    p = pcd1.getCheckPart() + ":" + pcd1.getRemark();
                                } else {
                                    if (pcd1.getPicPath().equals("")) {
                                        //String s1 = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                                        String s1 = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                                        flPicMap.put("pic2", s1);
                                    } else {
                                        flPicMap.put("pic2", MDoc.getImageStr(pcd1.getPicPath() + ja.get(u)));
                                        //flPicMap.put("pic2", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\12.png"));
                                    }
                                    flPicMap.put("pictureDescription2", pcd1.getCheckPart() + ":" + pcd1.getRemark());
                                    flPicMap.put("pictureDescription1", p);
                                    flPicMap.put("pic1", s);
                                    flPicList.add(flPicMap);
                                    // System.out.println("PDNULLp:"+p);
                                    // System.out.println("PDNULLs:"+s);
                                }
                            } else {
                                if (u % 2 == 0) {
                                    if (pcd1.getPicPath().equals("")) {
                                        //s = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                                        s = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                                    } else {
                                        s = MDoc.getImageStr(pcd1.getPicPath() + ja.get(u));
                                        //s = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\12.png");
                                    }
                                    p = pcd1.getCheckPart() + ":" + pcd1.getRemark();
                                } else {
                                    if (pcd1.getPicPath().equals("")) {
                                        //String s1 = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                                        String s1 = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                                        flPicMap.put("pic2", s1);
                                    } else {
                                        flPicMap.put("pic2", MDoc.getImageStr(pcd1.getPicPath() + ja.get(u)));
                                        //flPicMap.put("pic2", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\12.png"));
                                    }
                                    flPicMap.put("pictureDescription2", pcd1.getCheckPart() + ":" + pcd1.getRemark());
                                    flPicMap.put("pictureDescription1", p);
                                    flPicMap.put("pic1", s);
                                    flPicList.add(flPicMap);
                                    // System.out.println("PDNULLp:"+p);
                                    //  System.out.println("PDNULLs:"+s);
                                }
                            }
                        } else {
                            if (!storeS.equals("") && !storeP.equals("")) {
                                if (u % 2 != 0) {
                                    if (pcd1.getPicPath().equals("")) {
                                        //s = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                                        s = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                                    } else {
                                        s = MDoc.getImageStr(pcd1.getPicPath() + ja.get(u));
                                        //s = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\12.png");
                                    }
                                    p = pcd1.getCheckPart() + ":" + pcd1.getProblemDescription();
                                } else {
                                    if (pcd1.getPicPath().equals("")) {
                                        //String s1 = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                                        String s1 = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                                        flPicMap.put("pic2", s1);
                                    } else {
                                        flPicMap.put("pic2", MDoc.getImageStr(pcd1.getPicPath() + ja.get(u)));
                                        //flPicMap.put("pic2", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\12.png"));
                                    }
                                    flPicMap.put("pictureDescription2", pcd1.getCheckPart() + ":" + pcd1.getProblemDescription());
                                    flPicMap.put("pictureDescription1", p);
                                    flPicMap.put("pic1", s);
                                    flPicList.add(flPicMap);
                                    // System.out.println("sPnullP:"+p);
                                    //  System.out.println("sSnullS:"+s);
                                }
                            } else {
                                if (u % 2 == 0) {
                                    if (pcd1.getPicPath().equals("")) {
                                        //s = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                                        s = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                                    } else {
                                        s = MDoc.getImageStr(pcd1.getPicPath() + ja.get(u));
                                        //s = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\12.png");
                                    }
                                    p = pcd1.getCheckPart() + ":" + pcd1.getProblemDescription();
                                } else {
                                    if (pcd1.getPicPath().equals("")) {
                                        //String s1 = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                                        String s1 = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                                        flPicMap.put("pic2", s1);
                                    } else {
                                        //flPicMap.put("pic2", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\12.png"));
                                        flPicMap.put("pic2", MDoc.getImageStr(pcd1.getPicPath() + ja.get(u)));
                                    }
                                    flPicMap.put("pictureDescription2", pcd1.getCheckPart() + ":" + pcd1.getProblemDescription());
                                    flPicMap.put("pictureDescription1", p);
                                    flPicMap.put("pic1", s);
                                    flPicList.add(flPicMap);
                                    // System.out.println("sPnullP:"+p);
                                    // System.out.println("sSnullS:"+s);
                                }
                            }
                        }

                        int size = 0;
                        for (int x : jaSize) {
                            size += x;
                        }
                        // System.out.println("size:"+size);
                        if (size % 2 != 0 && u == (ja.size() - 1) && temp1 == sevenLevel.size()) {
                            //String s1 = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                            String s1 = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                            flPicMap.put("pic2", s1);
                            flPicMap.put("pictureDescription2", "");
                            flPicMap.put("pic1", s);
                            flPicMap.put("pictureDescription1", p);
                            flPicList.add(flPicMap);
                        } else if (u == (ja.size() - 1) && temp1 != sevenLevel.size() && size % 2 != 0) {
                            storeS = s;
                            storeP = p;
                        } else if (u == (ja.size() - 1) && temp1 != sevenLevel.size() && size % 2 == 0) {
                            storeP = "";
                            storeS = "";
                        }
                    } // for ja

                }
                forthLevelMap.put("flPicList", flPicList);
                forthLevelMap.put("seventhLevelList", seventhLevelList);
                forthLevelList.add(forthLevelMap);

                // System.out.println("seventhLevelList:"+seventhLevelList);
                //System.out.println("flPicList:"+flPicList);
                //System.out.println("forthLevelList:"+forthLevelList);
            }
        }
        dataMap.put("forthLevelList", forthLevelList);

        String s = "";
        String p = "";
        String storeS = "";
        String storeP = "";
        int temp2 = 0;
        List<Integer> jaSize = new ArrayList<>();
        List<ProblemCollectDetail> sevenLevel = problemCollectDetailMapper.getProDescByCheckIdAndpName4(checkId, "文明施工");
        List<Object> wmsgList = new ArrayList<>();
        List<Object> wmsgPicList = new ArrayList<>();
        if (sevenLevel.size() == 0) {
            HashMap<String, Object> wmsgMap = new HashMap<>();
            wmsgMap.put("problemDescription", "");
            wmsgList.add(wmsgMap);
            HashMap<String, Object> wmsgPicMap = new HashMap<>();
            wmsgPicMap.put("pic2", "");
            wmsgPicMap.put("pictureDescription2", "");
            wmsgPicMap.put("pic1", "");
            wmsgPicMap.put("pictureDescription1", "");
            wmsgPicList.add(wmsgPicMap);
            dataMap.put("wmsgPicList", wmsgPicList);
            dataMap.put("wmsgList", wmsgList);
        } else {
            for (ProblemCollectDetail pcd1 : sevenLevel) {
                HashMap<String, Object> wmsgMap = new HashMap<>();
                temp2++;
                if (!pcd1.getRemark().equals("")) {
                    wmsgMap.put("problemDescription", pcd1.getCheckPart() + ":" + pcd1.getRemark());
                    wmsgList.add(wmsgMap);
                } else {
                    wmsgMap.put("problemDescription", pcd1.getCheckPart() + ":" + pcd1.getProblemDescription());
                    wmsgList.add(wmsgMap);
                }

                //获取picName(pName4.equals("文明施工"))
                String picName = pcd1.getPicName();
                JSONArray ja = JSONArray.parseArray(picName);
                jaSize.add(ja.size());
                for (int u = 0; u < ja.size(); u++) {
                    HashMap<String, Object> wmsgPicMap = new HashMap<>();
                    if (!pcd1.getRemark().equals("")) {
                        if (!storeP.equals("") && !storeS.equals("")) {
                            if (u % 2 != 0) {
                                if (pcd1.getPicPath().equals("")) {
                                    //s = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                                    s = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                                } else {
                                    s = MDoc.getImageStr(pcd1.getPicPath() + ja.get(u));
                                    //s = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\12.png");
                                }
                                p = pcd1.getCheckPart() + ":" + pcd1.getRemark();
                            } else {
                                if (pcd1.getPicPath().equals("")) {
                                    //String s1 = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                                    String s1 = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                                    wmsgPicMap.put("pic2", s1);
                                } else {
                                    wmsgPicMap.put("pic2", MDoc.getImageStr(pcd1.getPicPath() + ja.get(u)));
                                    //wmsgPicMap.put("pic2", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\12.png")) ;
                                }
                                wmsgPicMap.put("pictureDescription2", pcd1.getCheckPart() + ":" + pcd1.getRemark());
                                wmsgPicMap.put("pictureDescription1", p);
                                wmsgPicMap.put("pic1", s);
                                wmsgPicList.add(wmsgPicMap);
                            }
                        } else {
                            if (u % 2 == 0) {
                                if (pcd1.getPicPath().equals("")) {
                                    //s = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                                    s = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                                } else {
                                    s = MDoc.getImageStr(pcd1.getPicPath() + ja.get(u));
                                    //s = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\12.png");
                                }
                                p = pcd1.getCheckPart() + ":" + pcd1.getRemark();
                            } else {
                                if (pcd1.getPicPath().equals("")) {
                                    //String s1 = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                                    String s1 = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                                    wmsgPicMap.put("pic2", s1);
                                } else {
                                    wmsgPicMap.put("pic2", MDoc.getImageStr(pcd1.getPicPath() + ja.get(u)));
                                    //wmsgPicMap.put("pic2", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\12.png")) ;
                                }
                                wmsgPicMap.put("pictureDescription2", pcd1.getCheckPart() + ":" + pcd1.getRemark());
                                wmsgPicMap.put("pictureDescription1", p);
                                wmsgPicMap.put("pic1", s);
                                wmsgPicList.add(wmsgPicMap);
                            }
                        }
                    } else {
                        if (!storeP.equals("") && !storeS.equals("")) {
                            if (u % 2 != 0) {
                                if (pcd1.getPicPath().equals("")) {
                                    //s = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                                    s = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                                } else {
                                    s = MDoc.getImageStr(pcd1.getPicPath() + ja.get(u));
                                    //s = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\12.png");
                                }
                                p = pcd1.getCheckPart() + ":" + pcd1.getProblemDescription();
                            } else {
                                if (pcd1.getPicPath().equals("")) {
                                    //String s1 = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                                    String s1 = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                                    wmsgPicMap.put("pic2", s1);
                                } else {
                                    wmsgPicMap.put("pic2", MDoc.getImageStr(pcd1.getPicPath() + ja.get(u)));
                                    //wmsgPicMap.put("pic2", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\12.png")) ;
                                }
                                wmsgPicMap.put("pictureDescription2", pcd1.getCheckPart() + ":" + pcd1.getProblemDescription());
                                wmsgPicMap.put("pictureDescription1", p);
                                wmsgPicMap.put("pic1", s);
                                wmsgPicList.add(wmsgPicMap);
                            }
                        } else {
                            if (u % 2 == 0) {
                                if (pcd1.getPicPath().equals("")) {
                                    //s = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                                    s = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                                } else {
                                    s = MDoc.getImageStr(pcd1.getPicPath() + ja.get(u));
                                    //s =MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\12.png");
                                }
                                p = pcd1.getCheckPart() + ":" + pcd1.getProblemDescription();
                            } else {
                                if (pcd1.getPicPath().equals("")) {
                                    //String s1 = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                                    String s1 = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                                    wmsgPicMap.put("pic2", s1);
                                } else {
                                    wmsgPicMap.put("pic2", MDoc.getImageStr(pcd1.getPicPath() + ja.get(u)));
                                    //wmsgPicMap.put("pic2", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\12.png")) ;
                                }
                                wmsgPicMap.put("pictureDescription2", pcd1.getCheckPart() + ":" + pcd1.getProblemDescription());
                                wmsgPicMap.put("pictureDescription1", p);
                                wmsgPicMap.put("pic1", s);
                                wmsgPicList.add(wmsgPicMap);
                            }
                        }
                    }

                    int size = 0;
                    for (int x : jaSize) {
                        size += x;
                    }

                    if (size % 2 != 0 && u == (ja.size() - 1) && temp2 == sevenLevel.size()) {
                        //String s1 = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                        String s1 = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                        wmsgPicMap.put("pic2", s1);
                        wmsgPicMap.put("pictureDescription2", "");
                        wmsgPicMap.put("pic1", s);
                        wmsgPicMap.put("pictureDescription1", p);
                        wmsgPicList.add(wmsgPicMap);
                    } else if (u == (ja.size() - 1) && temp2 != sevenLevel.size() && size % 2 != 0) {
                        storeP = p;
                        storeS = s;
                    } else if (u == (ja.size() - 1) && temp2 != sevenLevel.size() && size % 2 == 0) {
                        storeP = "";
                        storeS = "";
                    }
                }
                dataMap.put("wmsgPicList", wmsgPicList);
                //System.out.println("wmsgPicList:"+wmsgPicList);
            }
            dataMap.put("wmsgList", wmsgList);
        }


        //System.out.println("wmsgList:"+wmsgList);


        //所有管理行为中施工单位安全管理内容
        List<Object> sgList = new ArrayList<>();
        List<ProblemCollectDetail> getSgList = problemCollectDetailMapper.getSgList(checkId);
        for (ProblemCollectDetail pcd : getSgList) {
            HashMap<String, Object> sgMap = new HashMap<>();
            if (pcd.getRemark().equals("")) {
                sgMap.put("problemDescription", pcd.getCheckPart() + ":" + pcd.getProblemDescription());
            } else {
                sgMap.put("problemDescription", pcd.getCheckPart() + ":" + pcd.getRemark());
            }
            sgList.add(sgMap);
        }
        dataMap.put("sgList", sgList);

        //所有管理行为中监理单位安全管理内容
        List<Object> jlList = new ArrayList<>();
        List<ProblemCollectDetail> getJlList = problemCollectDetailMapper.getJlList(checkId);
        for (ProblemCollectDetail pcd : getJlList) {
            HashMap<String, Object> jlMap = new HashMap<>();
            if (pcd.getRemark().equals("")) {
                jlMap.put("problemDescription", pcd.getCheckPart() + ":" + pcd.getProblemDescription());
            } else {
                jlMap.put("problemDescription", pcd.getCheckPart() + ":" + pcd.getRemark());
            }
            jlList.add(jlMap);
        }
        dataMap.put("jlList", jlList);
        // System.out.println("dataMap:"+ dataMap);

        Date date1 = new Date();
        DateFormat d1 = new SimpleDateFormat("yyyyMMddhhmmss");
        String fileName = d1.format(date1);

        MDoc mdoc = new MDoc();
        String path = FileUtil.getServerFolderPath();
        File f1 = new File(path, "doc");
        if (!f1.exists()) {
            f1.mkdirs();
        }

        mdoc.createDoc(dataMap, path + "\\doc\\" + getBaseData.get(0).getProjectName().replace('#', '号') + "安全整改通知单" + fileName + ".doc", "ftl\\zgtzd.ftl");
        //MDoc.docToDocx("D:\\whutServer\\apache-tomcat-8.5.41\\webapps\\ROOT\\doc\\" + getBaseData.get(0).getProjectName().replace('#','号')+"安全整改通知单"+fileName + ".doc", "D:\\whutServer\\apache-tomcat-8.5.41\\webapps\\ROOT\\doc\\" + getBaseData.get(0).getProjectName().replace('#','号')+"安全整改通知单"+fileName +  ".doc");
        String result = urlProperties.getAddress() + "/doc/" + getBaseData.get(0).getProjectName().replace('#', '号') + "安全整改通知单" + fileName + ".doc";
        /*Date date7 = new Date();
        DateFormat d1 = new SimpleDateFormat("yyyyMMddhhmmss");
        String fileName = d1.format(date7) ;
        MDoc mdoc = new MDoc();
        mdoc.createDoc(dataMap, "E:\\tencent_File\\1296928795\\FileRecv\\yirui" + fileName + ".doc", "ftl\\zgtzd.ftl");
        MDoc.docToDocx("E:\\tencent_File\\1296928795\\FileRecv\\yirui" + fileName + ".doc", "E:\\tencent_File\\1296928795\\FileRecv\\yirui" + fileName + ".doc");
        String result = "E:\\tencent_File\\1296928795\\FileRecv\\yirui" + fileName + ".doc";*/
        return result;
    }

    @Override
    public String supervisionSpotCheckOfSgseftyInJsproject(int checkId) throws UnsupportedEncodingException {
        HashMap<String, Object> dataMap = new HashMap<>();
        List<ContractTaskProject> header = contracttaskprojectMapper.getHeader(checkId);
        String projectName = header.get(0).getProjectName();
        String progress = header.get(0).getProgress();
        String checkTime = header.get(0).getCheckTime();
        dataMap.put("projectName", projectName);
        dataMap.put("progress", progress);
        dataMap.put("checkTime", checkTime);
        List<ProblemCollectDetail> getPCD = problemCollectDetailMapper.getPCDByCheckId(checkId);
        String pName4 = "";
        int temp = 0;
        List<Object> checkList = new ArrayList<>();
        for (ProblemCollectDetail p : getPCD) {
            HashMap<String, Object> checkListMap = new HashMap<>();
            checkListMap.put("projectName", "检查项目：" + projectName);
            checkListMap.put("checkPart", "检查部位：" + p.getCheckPart());
            checkListMap.put("problemDes", "检查问题：" + p.getProblemDescription());
            checkListMap.put("suggestion", "处理建议：" + p.getSuggestion());
            temp++;
            if (temp != getPCD.size()) {
                pName4 += p.getpName4() + "、";
            } else {
                pName4 += p.getpName4();
            }
            checkList.add(checkListMap);
        }
        dataMap.put("checkList", checkList);
        dataMap.put("pName4", pName4);
        String maxRiskPoint = pointsCalculate.getMaxRiskPoint(getPCD);
        switch (maxRiskPoint) {
            case "1":
            case "提醒":
                dataMap.put("riskLevel", "4级隐患：符合要求");
            case "2":
                dataMap.put("riskLevel", "3级隐患：自查整改");
            case "3":
                dataMap.put("riskLevel", "2级隐患：限期整改");
            case "4":
                dataMap.put("riskLevel", "1级隐患：停工整改");
        }
        List<ContractCheckTask> sign = contractchecktaskMapper.getBaseData(checkId);
        if (sign.get(0).getSignPath() == null || sign.get(0).getSignPath().equals("")) {
            dataMap.put("jsUnitSign", MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png"));
            dataMap.put("jlUnitSign", MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png"));
            dataMap.put("sgUnitSign", MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png"));
            //dataMap.put("jsUnitSign", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\12.png"));
            //dataMap.put("jlUnitSign", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\12.png"));
            //dataMap.put("sgUnitSign", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\12.png"));
        } else {
            dataMap.put("jsUnitSign", MDoc.getImageStr(sign.get(0).getSignPath() + sign.get(0).getJsSign()));
            dataMap.put("jlUnitSign", MDoc.getImageStr(sign.get(0).getSignPath() + sign.get(0).getJlSign()));
            dataMap.put("sgUnitSign", MDoc.getImageStr(sign.get(0).getSignPath() + sign.get(0).getSgSign()));
            //dataMap.put("jsUnitSign", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png"));
            //dataMap.put("jlUnitSign", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png"));
            //dataMap.put("sgUnitSign", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png"));
        }
        Date t = new Date();
        SimpleDateFormat df = new SimpleDateFormat("yyyy年MM月dd日");
        dataMap.put("date", df.format(t));

        Date date1 = new Date();
        DateFormat d1 = new SimpleDateFormat("yyyyMMddhhmmss");
        String fileName = d1.format(date1) + "spotCheckReport";
        MDoc mdoc = new MDoc();
        String path = FileUtil.getServerFolderPath();
        File f1 = new File(path, "doc");
        if (!f1.exists()) {
            f1.mkdirs();
        }
        mdoc.createDoc(dataMap, path + "\\doc\\" + header.get(0).getProjectName().replace('#', '号') + "建设工程施工安全监督抽查记录" + fileName + ".doc", "ftl\\spotCheck.ftl");
        //MDoc.docToDocx("D:\\whutServer\\apache-tomcat-8.5.41\\webapps\\ROOT\\doc\\" + header.get(0).getProjectName().replace('#','号')+"建设工程施工安全监督抽查记录"+fileName + ".doc", "D:\\whutServer\\apache-tomcat-8.5.41\\webapps\\ROOT\\doc\\"+ header.get(0).getProjectName().replace('#','号')+"建设工程施工安全监督抽查记录"+fileName + ".doc");
        String result = urlProperties.getAddress() + "/doc/" + header.get(0).getProjectName().replace('#', '号') + "建设工程施工安全监督抽查记录" + fileName + ".doc";
       /* MDoc mdoc = new MDoc();
        Date date1 = new Date();
        DateFormat d1 = new SimpleDateFormat("yyyyMMddhhmmss");
        String fileName = d1.format(date1)+"spotCheckReport";
        mdoc.createDoc(dataMap, "E:\\tencent_File\\1296928795\\FileRecv\\yirui" + fileName + ".doc", "ftl\\spotCheck.ftl");
        MDoc.docToDocx("E:\\tencent_File\\1296928795\\FileRecv\\yirui" + fileName + ".doc", "E:\\tencent_File\\1296928795\\FileRecv\\yirui" + fileName + ".doc");
        String result = "E:\\tencent_File\\1296928795\\FileRecv\\yirui" + fileName + ".doc";*/
        return result;
    }

    @Override
    public String patrolReport(int checkId) throws UnsupportedEncodingException {
        HashMap<String, Object> dataMap = new HashMap<>();
        List<ContractTaskProject> header = contracttaskprojectMapper.getPatrolHeader(checkId);
        String projectName = header.get(0).getProjectName();
        String progress = header.get(0).getProgress();
        String jsUnit = header.get(0).getJsUnit();
        String sgUnit = header.get(0).getSgUnit();
        String jlUnit = header.get(0).getJlUnit();
        dataMap.put("projectName", projectName);
        dataMap.put("progress", progress);
        dataMap.put("jsUnit", jsUnit);
        dataMap.put("sgUnit", sgUnit);
        dataMap.put("jlUnit", jlUnit);

        List<ContractCheckTask> checkInfoList = contractchecktaskMapper.getCheckInfoByCheckId(checkId);
        String groupIdS = checkInfoList.get(0).getCheckGroupId();
        int groupId = Integer.parseInt(groupIdS);
        List<GroupMemberDetail> groupMemHead = groupMemberDetailMapper.getGroupHead(groupId);
        List<GroupMemberDetail> groupMem = groupMemberDetailMapper.getGroupMemb(groupId);
        String checkPeople = "";
        if (groupMemHead.size() == 0 && groupMem.size() == 0) {
            dataMap.put("checkPeople", " ");
        } else {
            for (GroupMemberDetail gmd : groupMemHead) {
                checkPeople += gmd.getUserName() + " ";
            }
            for (GroupMemberDetail gmd : groupMem) {
                checkPeople += gmd.getUserName() + " ";
            }
            dataMap.put("checkPeople", checkPeople);
        }


        List<ProblemCollectDetail> getCheckList = problemCollectDetailMapper.getPCDByCheckId(checkId);
        List<Object> sumList = new ArrayList<>();
        List<Object> checkList = new ArrayList<>();
        String pName4 = "";
        int temp = 0;
        for (ProblemCollectDetail pcd : getCheckList) {
            String picName = pcd.getPicName();
            JSONArray picNum = JSONArray.parseArray(picName);
            HashMap<String, Object> sumMap = new HashMap<>();
            if (pcd.getIsRemark().equals("N")) {
                sumMap.put("problemDes", pcd.getProblemDescription());
            } else {
                sumMap.put("problemDes", pcd.getRemark());
            }
            sumMap.put("suggestion", pcd.getSuggestion());
            if (picNum.size() == 0) {
                HashMap<String, Object> checkMap = new HashMap<>();
                checkMap.put("projectName", "检查项目：" + projectName);
                checkMap.put("checkPart", "检查部位：" + pcd.getCheckPart());
                if (pcd.getIsRemark().equals("N")) {
                    checkMap.put("problemDes", "检查问题：" + pcd.getProblemDescription());
                } else {
                    checkMap.put("problemDes", "检查问题：" + pcd.getRemark());
                }
                checkMap.put("suggestion", "建议措施：" + pcd.getSuggestion());
                List<Object> picList = new ArrayList<>();
                HashMap<String, Object> picMap = new HashMap<>();
//                picMap.put("pic", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png"));
                picMap.put("pic", MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png"));
                picList.add(picMap);
                checkMap.put("picList", picList);
                checkList.add(checkMap);
            } else {
                HashMap<String, Object> checkMap = new HashMap<>();
                checkMap.put("projectName", "检查项目：" + projectName);
                checkMap.put("checkPart", "检查部位：" + pcd.getCheckPart());
                if (pcd.getIsRemark().equals("N")) {
                    checkMap.put("problemDes", "检查问题：" + pcd.getProblemDescription());
                } else {
                    checkMap.put("problemDes", "检查问题：" + pcd.getRemark());
                }
                checkMap.put("suggestion", "建议措施：" + pcd.getSuggestion());
                List<Object> picList = new ArrayList<>();
                for (int i = 0; i < picNum.size(); i++) {
                    HashMap<String, Object> picMap = new HashMap<>();
                    picMap.put("pic", MDoc.getImageStr(pcd.getPicPath() + picNum.get(i))); //服务器
//                    picMap.put("pic", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\12.png")); //测试端
                    picList.add(picMap);
                }
                checkMap.put("picList", picList);
                checkList.add(checkMap);
            }
            sumList.add(sumMap);
            temp++;
            if (temp != getCheckList.size()) {
                pName4 += pcd.getpName4() + "、";
            } else {
                pName4 += pcd.getpName4();
            }
        }
        dataMap.put("sumList", sumList);
        dataMap.put("checkList", checkList);
        dataMap.put("pName4", pName4);
        if (getCheckList.get(0).getRiskPoint().equals("提醒")) {
            dataMap.put("riskLevel", "隐患等级：4级");
        } else {
            String maxRiskPoint = pointsCalculate.getMaxRiskPoint(getCheckList);
            switch (maxRiskPoint) {
                case "1":
                    dataMap.put("riskLevel", "隐患等级：4级");
                case "2":
                    dataMap.put("riskLevel", "隐患等级：3级");
                case "3":
                    dataMap.put("riskLevel", "隐患等级：2级");
                case "4":
                    dataMap.put("riskLevel", "隐患等级：1级");
            }
        }
        List<ContractCheckTask> sign = contractchecktaskMapper.getBaseData(checkId);
        String checkTime = sign.get(0).getFinishTime();
        dataMap.put("checkTime", checkTime);

        if (sign.get(0).getSignPath() == null || sign.get(0).getSignPath().equals("")) {
            dataMap.put("jsUnitSign", MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png"));
            dataMap.put("jlUnitSign", MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png"));
            dataMap.put("sgUnitSign", MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png"));
//            dataMap.put("jsUnitSign", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\12.png"));
//            dataMap.put("jlUnitSign", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\12.png"));
//            dataMap.put("sgUnitSign", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\12.png"));
        } else {
            dataMap.put("jsUnitSign", MDoc.getImageStr(sign.get(0).getSignPath() + sign.get(0).getJsSign()));
            dataMap.put("jlUnitSign", MDoc.getImageStr(sign.get(0).getSignPath() + sign.get(0).getJlSign()));
            dataMap.put("sgUnitSign", MDoc.getImageStr(sign.get(0).getSignPath() + sign.get(0).getSgSign()));
//            dataMap.put("jsUnitSign", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png"));
//            dataMap.put("jlUnitSign", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png"));
//            dataMap.put("sgUnitSign", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png"));
        }
        Date t = new Date();
        SimpleDateFormat df = new SimpleDateFormat("yyyy年MM月dd日");
        dataMap.put("date", df.format(t));
        Date date1 = new Date();
        DateFormat d1 = new SimpleDateFormat("yyyyMMddhhmmss");
        String fileName = d1.format(date1) + "patrolReport";
        MDoc mdoc = new MDoc();
        String path = FileUtil.getServerFolderPath();
        File f1 = new File(path, "doc");
        if (!f1.exists()) {
            f1.mkdirs();
        }
        mdoc.createDoc(dataMap, path + "\\doc\\" + header.get(0).getProjectName().replace('#', '号') + "巡查记录表" + fileName + ".doc", "ftl\\patrolReport.ftl");
        //MDoc.docToDocx("D:\\whutServer\\apache-tomcat-8.5.41\\webapps\\ROOT\\doc\\" +header.get(0).getProjectName().replace('#','号')+"巡查记录表" +fileName + ".doc", "D:\\whutServer\\apache-tomcat-8.5.41\\webapps\\ROOT\\doc\\" +header.get(0).getProjectName().replace('#','号')+"巡查记录表" +fileName + ".doc");
        String result = urlProperties.getAddress() + "/doc/" + header.get(0).getProjectName().replace('#', '号') + "巡查记录表" + fileName + ".doc";
//        MDoc mdoc = new MDoc();
//        Date date1 = new Date();
//        DateFormat d1 = new SimpleDateFormat("yyyyMMddhhmmss");
//        String fileName = d1.format(date1)+"potralCheckReport";
//        mdoc.createDoc(dataMap, "E:\\tencent_File\\1296928795\\FileRecv\\yirui" + fileName + ".doc", "ftl\\patrolReport.ftl");
//        MDoc.docToDocx("E:\\tencent_File\\1296928795\\FileRecv\\yirui" + fileName + ".doc", "E:\\tencent_File\\1296928795\\FileRecv\\yirui" + fileName + ".doc");
//        String result = "E:\\tencent_File\\1296928795\\FileRecv\\yirui" + fileName + ".doc";
        return result;
    }


    /**
     * 香港置地安全报告/质量报告
     */
    @Override
    public String getMXTQreport(int checkId, int projectId, int reportType) throws UnsupportedEncodingException {

        Integer taskId = contractchecktaskMapper.getTaskIdByCheckId(checkId);

        StandardChartTheme standardChartTheme = new StandardChartTheme("CN");
        //设置标题字体
        standardChartTheme.setExtraLargeFont(new Font("隶书", Font.BOLD, 20));
        //设置图例的字体
        standardChartTheme.setRegularFont(new Font("宋书", Font.PLAIN, 15));
        //设置轴向的字体
        standardChartTheme.setLargeFont(new Font("宋书", Font.PLAIN, 15));
        //应用主题样式
        DecimalFormat df = new DecimalFormat("0.00");
        DefaultPieDataset datasetPie = new DefaultPieDataset();
        DefaultCategoryDataset datasetBar = new DefaultCategoryDataset();
        int width = 718;
        int height = 468;
        ChartFactory.setChartTheme(standardChartTheme);
        Map<String, Object> dataMap = new HashMap<String, Object>();
        Date date = new Date();
        DateFormat d1 = new SimpleDateFormat("yyyyMMddhhmmss");
        DateFormat d2 = new SimpleDateFormat("yyyy");
        DateFormat d3 = new SimpleDateFormat("MM");
        DateFormat d4 = new SimpleDateFormat("dd");
        String day = d4.format(date);
        String month = d3.format(date);
        String year = d2.format(date);
        String fileName = d1.format(date);
        dataMap.put("day", day);
        dataMap.put("month", month);
        dataMap.put("year", year);
        final String Bar = "各检查分项";
        //一、工程概况
        List<ContractTaskProject> projectList = contracttaskprojectMapper.selectAllByCheckId(projectId);
        dataMap.put("projectName", projectList.get(0).getProjectName());
        dataMap.put("projectAddress", projectList.get(0).getArea());
        dataMap.put("jsUnit", projectList.get(0).getJlUnit());
        dataMap.put("jlUnit", projectList.get(0).getJlUnit());
        dataMap.put("sgUnit", projectList.get(0).getSgUnit());
        dataMap.put("projectType", projectList.get(0).getProjectType());
        dataMap.put("projectDescription", projectList.get(0).getProjectDescription());
        dataMap.put("jsUniter", projectList.get(0).getJsUniter());
        dataMap.put("jlUniter", projectList.get(0).getJlUniter());
        dataMap.put("sgUniter", projectList.get(0).getManager());

        //二、评估结果-----（一）综合评估结果 (二)各分项评估结果
        //由checkId拿到所有第三级信息
        List<ProblemCollectDetail> thirdIdProblemDetail = problemCollectDetailMapper.getAllThirdInfoMXTQ(checkId);
        List<Object> allFourthList = new ArrayList<>();
        //遍历第三级
        for (int i = 0; i < thirdIdProblemDetail.size(); i++) {
            double point3 = 0;
            int thirdId = thirdIdProblemDetail.get(i).getThirdId();
            //根据第三级id拿到它之下的所有第四级，转为jsonArray。上面不转也可以。
            List<ProblemCollectDetail> fourthIdProblemDetail = problemCollectDetailMapper.getAllFourthInfoMXTQ(checkId, thirdId);
            String fourthCalculateInfo = JSON.toJSONString(fourthIdProblemDetail, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
            JSONArray fourthPointsCalculateArray = JSONArray.parseArray(fourthCalculateInfo);

           /*double allweight4 = 0;
           for (int v = 0; v < fourthPointsCalculateArray.size(); v++) {
               JSONObject jsonObject = fourthPointsCalculateArray.getJSONObject(v);
               double Tweight4 = 0;
               int fourthId = jsonObject.getIntValue("fourthId");
               String trueweight4 = prefixsystemMapper.getWeight3ByThirdId(fourthId);
               Tweight4 = pointsCalculate.getPercentInstance(trueweight4);
               allweight4 += Tweight4;
           }*/

            //遍历第四级
            for (int j = 0; j < fourthPointsCalculateArray.size(); j++) {
                Map<String, Object> allFourthMap = new HashMap<>();
                JSONObject part2InnerObject = fourthPointsCalculateArray.getJSONObject(j);
                //算第四级权重和
                double allweight4 = 0;
                List<ProblemCollectDetail> countFourthWeight = problemCollectDetailMapper.getAllFourthInfoMXTQ(checkId, part2InnerObject.getIntValue("thirdId"));
                //为什么还要遍历第四级？？？
                for (int v = 0; v < countFourthWeight.size(); v++) {
                    double Tweight4 = 0;
                    int fourthId = countFourthWeight.get(v).getFourthId();

                    //更改取权重的表
                    String newWeight4 = editableweightpsMapper.getWeightByNumber(fourthId, taskId);
                    if (StringUtils.isNotBlank(newWeight4)) {
                        Tweight4 = pointsCalculate.getPercentInstance(newWeight4);
                    } else {
                        String trueweight4 = prefixsystemMapper.getWeight3ByThirdId(fourthId);
                        Tweight4 = pointsCalculate.getPercentInstance(trueweight4);
                    }

                    allweight4 += Tweight4;
                }
                allFourthMap.put("pName4", part2InnerObject.getString("pName4"));

                //单条记录的3、4级权重
                double weight3 = 0;
                double weight4 = 0;
                int part2FourthId = part2InnerObject.getIntValue("fourthId");
                int part2ThirdId = part2InnerObject.getIntValue("thirdId");

                //更改权重来源
                String newWeight44 = editableweightpsMapper.getWeightByNumber(part2FourthId, taskId);
                if (StringUtils.isNotBlank(newWeight44)) {
                    weight4 = pointsCalculate.getPercentInstance(newWeight44);
                } else {
                    weight4 = pointsCalculate.getPercentInstance(part2InnerObject.getString("weight4"));
                }

                String newWeight33 = editableweightpsMapper.getWeightByNumber(part2ThirdId, taskId);
                if (StringUtils.isNotBlank(newWeight33)) {
                    weight3 = pointsCalculate.getPercentInstance(newWeight33);
                } else {
                    weight3 = pointsCalculate.getPercentInstance(part2InnerObject.getString("weight3"));
                }

                //1、拿到四级下的所有有问题的六级数组，problemCollect
                List<ProblemCollectDetail> sixthPoints = problemCollectDetailMapper.getsixthPoints(checkId, part2FourthId);
                String pointName6Info = JSON.toJSONString(sixthPoints, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray sixthPointsArray = JSONArray.parseArray(pointName6Info);

                //总减
                double calculatePoint6 = 0;
                //单项减
                double calculatePoint66 = 0;
                //总不减
                double calculateTruePoint = 0;
                List<Object> allSixthList = new ArrayList<>();
                for (int y = 0; y < sixthPointsArray.size(); y++) {
                    Map<String, Object> allSixMap = new HashMap<>();
                    JSONObject sixPointObject = sixthPointsArray.getJSONObject(y);
                    allSixMap.put("pName6", sixPointObject.getString("pName6"));
                    int deductSixthId = sixPointObject.getIntValue("sixthId");
                    float deductPointsSumFloat = problemCollectDetailMapper.getdeductSum(checkId, deductSixthId);
                    double deductPointsSum = Double.valueOf(String.valueOf(deductPointsSumFloat));
                    double truePoint = Double.parseDouble(sixPointObject.getString("point6"));
                    allSixMap.put("duePoint", truePoint);
                    allSixMap.put("deductPoint", deductPointsSum);
                    allSixthList.add(allSixMap);
                    if (truePoint <= deductPointsSum) {
                        calculatePoint66 = 0;
                    } else {
                        calculatePoint66 = truePoint - deductPointsSum;
                    }
                    calculateTruePoint += truePoint;
                    calculatePoint6 += calculatePoint66;
                }

                //2、无问题项得分，无问题项不扣分
                double noProblemPoint = 0;
                List<Object> noProblemSixthIdList = uncheckeditemsMapper.getNoProblemSixthId(checkId, part2InnerObject.getIntValue("fourthId"));
                String noProblemSixthIdInfo = JSON.toJSONString(noProblemSixthIdList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray noProblemSixthArray = JSONArray.parseArray(noProblemSixthIdInfo);
                for (int m = 0; m < noProblemSixthArray.size(); m++) {
                    Map<String, Object> allSixMap = new HashMap<>();
                    int noProblemSixthId = noProblemSixthArray.getIntValue(m);
                    allSixMap.put("pName6", prefixsystemMapper.getName4ByName4Id(noProblemSixthId));
                    allSixMap.put("duePoint", prefixsystemMapper.getPoint4ByPoint4Id(noProblemSixthId));
                    allSixMap.put("deductPoint", 0);
                    allSixthList.add(allSixMap);
                    double noProblem = Double.parseDouble(prefixsystemMapper.getPoint4ByPoint4Id(noProblemSixthId));
                    noProblemPoint += noProblem;
                }

                //3、prefixsystem体系里面除了problemCollect和uncheckedItems里的第六级id，未涉及
                List<Integer> wsjList = prefixsystemMapper.getWSJList(checkId, part2InnerObject.getIntValue("fourthId"));
                for (int g = 0; g < wsjList.size(); g++) {
                    Map<String, Object> allSixMap = new HashMap<>();
                    int wsjSixthId = wsjList.get(g);
                    allSixMap.put("pName6", prefixsystemMapper.getName4ByName4Id(wsjSixthId));
                    allSixMap.put("duePoint", prefixsystemMapper.getPoint4ByPoint4Id(wsjSixthId));
                    allSixMap.put("deductPoint", "未涉及");
                    allSixthList.add(allSixMap);
                }

                allFourthMap.put("allSixthList", allSixthList);
                System.out.println("第六级扣过的分数总分:" + calculatePoint6 + "没有问题的总分:" + noProblemPoint + "第六级总分:" + calculateTruePoint);
                double checkItemPoint = (calculatePoint6 + noProblemPoint) / (calculateTruePoint + noProblemPoint) * 100;
                point3 += checkItemPoint * (weight4 / allweight4);

                //根据最大风险等级以及数量确定分数上限，表里没数据，就取100。
                List<ProblemCollectDetail> checkItemCalcuList = problemCollectDetailMapper.getAllFourthInfo(checkId, part2FourthId);
                String maxFourthRiskPoint = pointsCalculate.getMaxRiskPoint(checkItemCalcuList);
                int maxFourthRiskPointNum = problemCollectDetailMapper.getRiskPointCount(checkId, part2FourthId, maxFourthRiskPoint);
                double limitFourhPoint = Double.parseDouble((pointlimitMapper.getLimitPointByInfo(String.valueOf(maxFourthRiskPointNum), maxFourthRiskPoint)) == null ? "100" : pointlimitMapper.getLimitPointByInfo(String.valueOf(maxFourthRiskPointNum), maxFourthRiskPoint));
                //两分数相比，即checkItemPoint不能超过pointLimit里的分数上限
                if (checkItemPoint > limitFourhPoint) {
                    checkItemPoint = limitFourhPoint;
                }
                String s = df.format(checkItemPoint);
                allFourthMap.put("point4", s);
                allFourthList.add(allFourthMap);

                //把计算出来4级的分存到allpointsave里去，number是4级的number
                int allPointSaveFourthPointCount = allpointsaveMapper.getAllPointCountByCheckId(checkId, part2FourthId);
                if (allPointSaveFourthPointCount != 0) {
                    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
                    Date date1 = new Date(System.currentTimeMillis());
                    String lastEditTime = formatter.format(date1);
                    allpointsaveMapper.updateAllPoint(checkId, s, part2FourthId, lastEditTime);
                } else {
                    Allpointsave allpointsave = new Allpointsave();
                    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
                    Date date1 = new Date(System.currentTimeMillis());
                    allpointsave.setNewCreateTime(formatter.format(date1));
                    allpointsave.setLastEditTime(formatter.format(date1));
                    allpointsave.setProjectId(projectId);
                    allpointsave.setCheckId(checkId);
                    allpointsave.setNumber(part2FourthId);
                    allpointsave.setPoint(s);
                    allpointsaveMapper.insert(allpointsave);
                }
            }

            //存3级的分
            String t = df.format(point3);
            int allPointSaveThirdPointCount = allpointsaveMapper.getAllPointCountByCheckId(checkId, thirdId);
            if (allPointSaveThirdPointCount != 0) {
                SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
                Date date1 = new Date(System.currentTimeMillis());
                String lastEditTime = formatter.format(date1);
                allpointsaveMapper.updateAllPoint(checkId, t, thirdId, lastEditTime);
            } else {
                Allpointsave allpointsave = new Allpointsave();
                SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
                Date date1 = new Date(System.currentTimeMillis());
                allpointsave.setNewCreateTime(formatter.format(date1));
                allpointsave.setLastEditTime(formatter.format(date1));
                allpointsave.setProjectId(projectId);
                allpointsave.setCheckId(checkId);
                allpointsave.setNumber(thirdId);
                allpointsave.setPoint(t);
                allpointsaveMapper.insert(allpointsave);
            }
        }
        dataMap.put("allFourthList", allFourthList);

        //(一)、综合评估结果
        List<Object> thirdList = new ArrayList<>();
        List<Object> glFourthList = new ArrayList<>();
        //总分（单项分*权重）
        double allPoint = 0;
        //权重和
        double allWeight = 0;

        //遍历三级的非管理行为
        for (int i = 0; i < thirdIdProblemDetail.size(); i++) {
            if (!thirdIdProblemDetail.get(i).getpName1().equals("管理行为")) {
                Map<String, Object> thirdMap = new HashMap<>();
                //取出上面刚存的第三级的分数
                String point3 = allpointsaveMapper.getPointByCheckIdAndNumber(checkId, thirdIdProblemDetail.get(i).getThirdId());

                //更改权重来源
                int thirdId = thirdIdProblemDetail.get(i).getThirdId();
                String weight3 = editableweightpsMapper.getWeightByNumber(thirdId, taskId);
                if (StringUtils.isBlank(weight3)) {
                    weight3 = thirdIdProblemDetail.get(i).getWeight3();
                }

                thirdMap.put("pName3", thirdIdProblemDetail.get(i).getpName3());
                thirdMap.put("weight3", weight3);
                thirdMap.put("point3", point3);
                allPoint += Double.valueOf(point3) * pointsCalculate.getPercentInstance(weight3);
                allWeight += pointsCalculate.getPercentInstance(weight3);
                thirdList.add(thirdMap);
            }
        }

        //遍历四级的管理行为
        List<ProblemCollectDetail> fourthIdProblemDetail = problemCollectDetailMapper.getAllCheckFourthInfoMXTQ(checkId);
        for (int i = 0; i < fourthIdProblemDetail.size(); i++) {
            if (fourthIdProblemDetail.get(i).getpName1().equals("管理行为")) {
                Map<String, Object> glFourthMap = new HashMap<>();
                String point4 = allpointsaveMapper.getPointByCheckIdAndNumber(checkId, fourthIdProblemDetail.get(i).getFourthId());

                //更改权重来源
                int fourthId = fourthIdProblemDetail.get(i).getFourthId();
                String weight4 = editableweightpsMapper.getWeightByNumber(fourthId, taskId);
                if (StringUtils.isBlank(weight4)) {
                    weight4 = fourthIdProblemDetail.get(i).getWeight4();
                }

                glFourthMap.put("pName4", fourthIdProblemDetail.get(i).getpName4());
                glFourthMap.put("weight4", weight4);
                glFourthMap.put("point4", point4);
                allPoint += Double.valueOf(point4) * pointsCalculate.getPercentInstance(weight4);
                allWeight += pointsCalculate.getPercentInstance(weight4);
                glFourthList.add(glFourthMap);
            }
        }

        //总得分：（Σ分项得分*分项权重）/Σ分项权重
        String allOverPoint = df.format(allPoint / allWeight);
        dataMap.put("thirdList", thirdList);
        dataMap.put("glFourthList", glFourthList);
        dataMap.put("allOverPoint", allOverPoint);

        //(三)、各专业问题分布情况
        List<Object> pName4Info = problemCollectDetailMapper.getAllName4(checkId);
        int allProblemNum = problemCollectDetailMapper.getAllNum(checkId);
        dataMap.put("allProblemNum", allProblemNum);
        String name4 = JSON.toJSONString(pName4Info, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        JSONArray name4Array = JSONArray.parseArray(name4);
        List<Object> part3List = new ArrayList<Object>();
        for (int m = 0; m < name4Array.size(); m++) {
            Map<String, Object> part3Map = new HashMap<String, Object>();
            int pName4Id = name4Array.getIntValue(m);
            String pName4 = prefixsystemMapper.getName4ByName4Id(pName4Id);
            int name4Num = problemCollectDetailMapper.countName4(pName4Id, checkId);
            String percent = pointsCalculate.caculateToPercent(name4Num, allProblemNum);
            part3Map.put("no", m + 1);
            part3Map.put("pName4", pName4);
            part3Map.put("problemNum", name4Num);
            part3Map.put("percent", percent);
            datasetPie.setValue(pName4 + ":" + percent, new Double(name4Num));
            datasetBar.addValue(name4Num, Bar, pName4);
            part3List.add(part3Map);
        }
        dataMap.put("problemList", part3List);
        //(四)、各专业问题饼图与直方图
        try {
            JFreeChart chart = ChartFactory.createPieChart("现场施工问题分布饼图", datasetPie, true, true, false);
            final PiePlot plot = (PiePlot) chart.getPlot();
            plot.setStartAngle(270);
            plot.setForegroundAlpha(0.90f);
            plot.setInteriorGap(0.02);
            chart.getLegend().setVisible(false);

            //地址
            //File pieChart = new File("D:\\Work\\LabWork\\YiRui\\文档\\Test\\" + fileName + "pieChart.png");
            File pieChart = new File("D:\\whutServer\\generatedCharts\\" + fileName + "pieChart.png");

            ChartUtils.saveChartAsPNG(pieChart, chart, width, height);
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            JFreeChart barChart = ChartFactory.createBarChart("现场施工问题分布直方图",
                    "",
                    "数量",
                    datasetBar,
                    PlotOrientation.VERTICAL,
                    true, true, false);
            CategoryPlot plot = (CategoryPlot) barChart.getPlot();
            plot.getRenderer().setSeriesPaint(0, new Color(5, 87, 232));
            BarRenderer barRenderer = (BarRenderer) plot.getRenderer();
            barRenderer.setDefaultItemLabelGenerator(new StandardCategoryItemLabelGenerator());
            barRenderer.setDefaultItemLabelsVisible(true);
            barRenderer.setItemLabelAnchorOffset(-20D);
            barRenderer.setMaximumBarWidth(0.2);
            CategoryAxis categoryAxis = plot.getDomainAxis();
            categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);

            //地址
            //File barChartFile = new File("D:\\Work\\LabWork\\YiRui\\文档\\Test\\" + fileName + "barChart.png");
            File barChartFile = new File("D:\\whutServer\\generatedCharts\\" + fileName + "barChart.png");

            ChartUtils.saveChartAsPNG(barChartFile, barChart, width, height);
        } catch (Exception e) {
            e.printStackTrace();
        }

        //地址
        //dataMap.put("pic6", MDoc.getImageStr("D:\\Work\\LabWork\\YiRui\\文档\\Test\\" + fileName + "pieChart.png"));
        //dataMap.put("pic7", MDoc.getImageStr("D:\\Work\\LabWork\\YiRui\\文档\\Test\\" + fileName + "barChart.png"));
        dataMap.put("pic6", MDoc.getImageStr("D:\\whutServer\\generatedCharts\\" + fileName + "pieChart.png"));
        dataMap.put("pic7", MDoc.getImageStr("D:\\whutServer\\generatedCharts\\" + fileName + "barChart.png"));

        //三、改进建议
        List<Object> part4List = new ArrayList<Object>();
        List<Object> pName1Info = problemCollectDetailMapper.getAllName1Id(checkId);
        String name1 = JSON.toJSONString(pName1Info, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        JSONArray name1Array = JSONArray.parseArray(name1);
        for (int i = 0; i < name1Array.size(); i++) {
            List<Object> part4InnerList = new ArrayList<Object>();
            Map<String, Object> part4Map = new HashMap<String, Object>();
            String pName1 = prefixsystemMapper.getName4ByName4Id(name1Array.getIntValue(i));
            List<Summary> summaryList = summaryMapper.getSummaryInfo(checkId, name1Array.getIntValue(i));
            String summaryInfo = JSON.toJSONString(summaryList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
            JSONArray summaryInfoArray = JSONArray.parseArray(summaryInfo);
            for (int j = 0; j < summaryInfoArray.size(); j++) {
                Map<String, Object> part4InnerMap = new HashMap<String, Object>();
                JSONObject part4InnerObject = summaryInfoArray.getJSONObject(j);
                String part4pNname4 = prefixsystemMapper.getName4ByName4Id(part4InnerObject.getIntValue("fourthId"));
                part4InnerMap.put("pName4", part4pNname4);
                part4InnerMap.put("summary", part4InnerObject.getString("summary"));
                part4InnerList.add(part4InnerMap);
            }
            if (pName1.equals("安全检查")) {
                part4Map.put("pName1", "安全");
            } else if (pName1.equals("质量检查")) {
                part4Map.put("pName1", "质量");
            } else if (pName1.equals("管理行为")) {
                part4Map.put("pName1", "管理行为");
            } else if (pName1.equals("设备检查")) {
                part4Map.put("pName1", "设备检查");
            }
            part4Map.put("summaryInnerList", part4InnerList);
            part4List.add(part4Map);
        }
        dataMap.put("summaryList", part4List);

        //四、问题汇总表
        List<Object> partProblemList = new ArrayList<Object>();
        for (int i = 0; i < name1Array.size(); i++) {
            List<Object> partProblemName1List = new ArrayList<Object>();
            Map<String, Object> partProblemMap = new HashMap<String, Object>();
            String pName1 = prefixsystemMapper.getName4ByName4Id(name1Array.getIntValue(i));
            List<Object> problemName4List = problemCollectDetailMapper.getAllName4ByName1(checkId, pName1);
            String problemName4Info = JSON.toJSONString(problemName4List, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
            JSONArray problemName4Array = JSONArray.parseArray(problemName4Info);
            for (int k = 0; k < problemName4Array.size(); k++) {
                List<ProblemCollectDetail> partProblemDetailList = problemCollectDetailMapper.getAllFourthInfo(checkId, problemName4Array.getIntValue(k));
                String partProblemDetailInfo = JSON.toJSONString(partProblemDetailList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray partProblemDetailArray = JSONArray.parseArray(partProblemDetailInfo);
                String problemName4 = prefixsystemMapper.getName4ByName4Id(problemName4Array.getIntValue(k));
                for (int j = 0; j < partProblemDetailArray.size(); j++) {
                    Map<String, Object> partProblemName1Map = new HashMap<String, Object>();
                    JSONObject partProblemObject = partProblemDetailArray.getJSONObject(j);
                    String problemDescription = partProblemObject.getString("problemDescription");
                    String riskPoint = partProblemObject.getString("riskPoint");
                    if (partProblemObject.getString("isRemark").equals("N")) {
                        partProblemName1Map.put("problemDescription", problemDescription);
                    } else if (partProblemObject.getString("isRemark").equals("Y")) {
                        partProblemName1Map.put("problemDescription", partProblemObject.getString("remark"));
                    }
                    partProblemName1Map.put("riskPoint", riskPoint);
                    partProblemName1Map.put("pName4", problemName4);
                    partProblemName1List.add(partProblemName1Map);
                }
            }
            if (pName1.equals("安全检查")) {
                partProblemMap.put("pName1", "安全");
            } else if (pName1.equals("质量检查")) {
                partProblemMap.put("pName1", "质量");
            } else if (pName1.equals("管理行为")) {
                partProblemMap.put("pName1", "管理行为");
            } else if (pName1.equals("设备检查")) {
                partProblemMap.put("pName1", "设备检查");
            }
            partProblemMap.put("fourthProblemList", partProblemName1List);
            partProblemList.add(partProblemMap);
        }
        dataMap.put("allProblemList", partProblemList);
        int txNum = problemCollectDetailMapper.getAllRiskPointCountByType(checkId, "提醒");
        int oneNum = problemCollectDetailMapper.getAllRiskPointCountByType(checkId, "1");
        int twoNum = problemCollectDetailMapper.getAllRiskPointCountByType(checkId, "2");
        int threeNum = problemCollectDetailMapper.getAllRiskPointCountByType(checkId, "3");
        int fourNum = problemCollectDetailMapper.getAllRiskPointCountByType(checkId, "4");
        dataMap.put("txNum", txNum);
        dataMap.put("oneNum", oneNum);
        dataMap.put("twoNum", twoNum);
        dataMap.put("threeNum", threeNum);
        dataMap.put("fourNum", fourNum);
        String txPercent = pointsCalculate.caculateToPercent(txNum, allProblemNum);
        String onePercent = pointsCalculate.caculateToPercent(oneNum, allProblemNum);
        String twoPercent = pointsCalculate.caculateToPercent(twoNum, allProblemNum);
        String threePercent = pointsCalculate.caculateToPercent(threeNum, allProblemNum);
        String fourPercent = pointsCalculate.caculateToPercent(fourNum, allProblemNum);
        dataMap.put("txPercent", txPercent);
        dataMap.put("onePercent", onePercent);
        dataMap.put("twoPercent", twoPercent);
        dataMap.put("threePercent", threePercent);
        dataMap.put("fourPercent", fourPercent);
        //第二部分，各部分工程检查情况
        String section2pName1 = "";
        List<Object> section2List = new ArrayList<Object>();
        for (int b = 0; b < name1Array.size(); b++) {
            Map<String, Object> section2Name1Map = new HashMap<String, Object>();
            List<Object> section2name1List = new ArrayList<Object>();
            String section2name1 = prefixsystemMapper.getName4ByName4Id(name1Array.getIntValue(b));
            if (section2name1.equals("安全检查")) {
                section2pName1 = "安全问题";
            } else if (section2name1.equals("质量检查")) {
                section2pName1 = "质量问题";
            } else if (section2name1.equals("管理行为")) {
                section2pName1 = "管理体系及管理动作";
            }
            section2Name1Map.put("section2pName1", section2pName1);
            List<Object> section2Name4Info = problemCollectDetailMapper.getAllName4ByName1(checkId, section2name1);
            String section2Name44 = JSON.toJSONString(section2Name4Info, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
            JSONArray section2Name4Array = JSONArray.parseArray(section2Name44);
            for (int w = 0; w < section2Name4Array.size(); w++) {
                Map<String, Object> section2Name4Map = new HashMap<String, Object>();
                List<Object> section2Name4List = new ArrayList<Object>();
                int section2Name4Id = section2Name4Array.getIntValue(w);
                String section2Name4 = prefixsystemMapper.getName4ByName4Id(section2Name4Id);
                List<ProblemCollectDetail> section2Name6Info = problemCollectDetailMapper.getAllName6InfoByName4(checkId, section2Name4Id, section2name1);
                String section2Name66 = JSON.toJSONString(section2Name6Info, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray section2Name6Array = JSONArray.parseArray(section2Name66);
                for (int c = 0; c < section2Name6Array.size(); c++) {
                    Map<String, Object> section2Name6Map = new HashMap<String, Object>();
                    List<Object> picList = new ArrayList<Object>();
                    JSONObject section2Name6Object = section2Name6Array.getJSONObject(c);
                    section2Name6Map.put("section2pName6No", c + 1);
                    section2Name6Map.put("section2pName6", section2Name6Object.getString("pName6"));
                    section2Name6Map.put("section2pName5", section2Name6Object.getString("pName5"));
                    section2Name6Map.put("section2RiskLevel", section2Name6Object.getString("riskPoint"));
                    section2Name6Map.put("section2CheckPart", section2Name6Object.getString("checkPart"));
                    section2Name6Map.put("section2ProblemNum", section2Name6Object.getString("problemQua"));
                    if (section2Name6Object.getString("isRemark").equals("N")) {
                        section2Name6Map.put("section2problemDescription", section2Name6Object.getString("problemDescription"));
                    } else if (section2Name6Object.getString("isRemark").equals("Y")) {
                        section2Name6Map.put("section2problemDescription", section2Name6Object.getString("remark"));
                    }
                    section2Name6Map.put("section2normsProvison", section2Name6Object.getString("normsProvison"));
                    section2Name6Map.put("section2suggestion", section2Name6Object.getString("suggestion"));
                    String section2picPath = section2Name6Object.getString("picPath");
                    String picName = section2Name6Object.getString("picName");
                    JSONArray ja = JSONArray.parseArray(picName);
                    if (ja.size() == 0) {

                        //地址
                        //String s = MDoc.getImageStr("D:\\Work\\LabWork\\YiRui\\文档\\Test\\noPic.png");
                        String s = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");

                        picList.add(s);
                    } else {
                        for (int o = 0; o < ja.size(); o++) {
                            String s="";
                            if( "prod".equals(profiles.getActives()) ){
                                s = MDoc.getImageStr(section2picPath + ja.getString(o));
                            }
                            //地址
                            //String s = MDoc.getImageStr("D:\\Work\\LabWork\\YiRui\\文档\\Test\\noPic.png");

                            picList.add(s);
                        }
                    }
                    section2Name6Map.put("picList", picList);
                    section2Name4List.add(section2Name6Map);

                }
                section2Name4Map.put("section2pName4", section2Name4);
                section2Name4Map.put("section2Name4List", section2Name4List);
                section2name1List.add(section2Name4Map);
            }
            section2Name1Map.put("section2Name1List", section2name1List);
            section2List.add(section2Name1Map);
        }
        dataMap.put("section2List", section2List);
        MDoc mdoc = new MDoc();
        String path = FileUtil.getServerFolderPath();
        File f1 = new File(path, "doc");
        if (!f1.exists()) {
            f1.mkdirs();
        }
        String result = "";
        if (reportType == 8) {
            //地址
            //mdoc.createDoc(dataMap, "D:\\Work\\LabWork\\YiRui\\文档\\Test\\" + projectList.get(0).getProjectName().replace('#','号')+"安全报告"+fileName + ".doc", "ftl\\aqMXTQ.ftl");
            mdoc.createDoc(dataMap, path + "\\doc\\" + projectList.get(0).getProjectName().replace('#', '号') + "安全报告" + fileName + ".doc", "ftl\\aqMXTQ.ftl");
            //MDoc.docToDocx("D:\\Work\\LabWork\\YiRui\\文档\\Test\\" + projectList.get(0).getProjectName().replace('#','号')+"安全报告"+fileName + ".doc", "D:\\Work\\LabWork\\YiRui\\文档\\Test\\" + projectList.get(0).getProjectName().replace('#','号')+"安全报告"+fileName + ".doc");
            //MDoc.docToDocx("D:\\whutServer\\apache-tomcat-8.5.41\\webapps\\ROOT\\doc\\" + projectList.get(0).getProjectName().replace('#','号')+"安全报告"+fileName + ".doc", "D:\\whutServer\\apache-tomcat-8.5.41\\webapps\\ROOT\\doc\\" + projectList.get(0).getProjectName().replace('#','号')+"安全报告"+fileName + ".doc");
            result = urlProperties.getAddress() + "/doc/" + projectList.get(0).getProjectName().replace('#', '号') + "安全报告" + fileName + ".doc";
        } else if (reportType == 9) {
            //地址
            //mdoc.createDoc(dataMap, "D:\\Work\\LabWork\\YiRui\\文档\\Test\\" + projectList.get(0).getProjectName().replace('#','号')+"质量报告"+fileName + ".doc", "ftl\\Risk2.0.ftl");
            mdoc.createDoc(dataMap, path + "\\doc\\" + projectList.get(0).getProjectName().replace('#', '号') + "质量报告" + fileName + ".doc", "ftl\\Risk2.0.ftl");
            //MDoc.docToDocx("D:\\Work\\LabWork\\YiRui\\文档\\Test\\" + projectList.get(0).getProjectName().replace('#','号')+"质量报告"+fileName + ".doc", "D:\\Work\\LabWork\\YiRui\\文档\\Test\\"+ projectList.get(0).getProjectName().replace('#','号')+"质量报告"+fileName +".doc");
            //MDoc.docToDocx("D:\\whutServer\\apache-tomcat-8.5.41\\webapps\\ROOT\\doc\\" + projectList.get(0).getProjectName().replace('#','号')+"质量报告"+fileName + ".doc", "D:\\whutServer\\apache-tomcat-8.5.41\\webapps\\ROOT\\doc\\"+ projectList.get(0).getProjectName().replace('#','号')+"质量报告"+fileName +".doc");
            result = urlProperties.getAddress() + "/doc/" + projectList.get(0).getProjectName().replace('#', '号') + "质量报告" + fileName + ".doc";
        }
        return result;
    }

    /**
     * 可视化安全报告
     */
    @Override
    public String getVisualizationReport(int checkId, int projectId) throws UnsupportedEncodingException {
        DecimalFormat df = new DecimalFormat("0.00");
        Map<String, Object> dataMap = new HashMap<String, Object>();
        Date date = new Date();
        DateFormat d1 = new SimpleDateFormat("yyyyMMddhhmmss");
        DateFormat d2 = new SimpleDateFormat("yyyy");
        DateFormat d3 = new SimpleDateFormat("MM");
        DateFormat d4 = new SimpleDateFormat("dd");
        String day = d4.format(date);
        String month = d3.format(date);
        String year = d2.format(date);
        String fileName = d1.format(date);
        dataMap.put("day", day);
        dataMap.put("month", month);
        dataMap.put("year", year);
        List<String> type3List = new ArrayList<String>();
        type3List.add("2");
        type3List.add("3");
        type3List.add("4");
        //工程概况部分，来自ctp的工程信息
        List<ContractTaskProject> projectList = contracttaskprojectMapper.selectAllByCheckId(projectId);
        String project = JSON.toJSONString(projectList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        JSONArray projectArray = JSONArray.parseArray(project);
        JSONObject projectObject = projectArray.getJSONObject(0);
        dataMap.put("projectName", projectObject.getString("projectName"));
        dataMap.put("projectAddress", projectObject.getString("area"));
        dataMap.put("jsUnit", projectObject.getString("jsUnit"));
        dataMap.put("jlUnit", projectObject.getString("jlUnit"));
        dataMap.put("sgUnit", projectObject.getString("sgUnit"));
        dataMap.put("projectType", projectObject.getString("projectType"));
        dataMap.put("projectPrice", projectObject.getString("projectPrice"));
        dataMap.put("dangerItem", projectObject.getString("dangerItem"));
        dataMap.put("remark", projectObject.getString("remark"));
        dataMap.put("projectDescription", projectObject.getString("projectDescription"));
        String js = projectObject.getString("jsUniter");
        String jl = projectObject.getString("jlUniter");
        String sg = projectObject.getString("manager");
        dataMap.put("jsUniter", js);
        dataMap.put("jlUniter", jl);
        dataMap.put("sgUniter", sg);
        //工程概况部分，来自设备信息表的设备信息部分
        List<Equipinfo> equipinfoList = equipinfoMapper.getAllByProjectId(projectId);
        String equip = JSON.toJSONString(equipinfoList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        JSONArray equipArray = JSONArray.parseArray(equip);
        List<Object> equipList = new ArrayList<Object>();
        if (equipArray.size() == 0) {
            Map<String, Object> eqMap = new HashMap<String, Object>();
            eqMap.put("equipType", "\\");
            eqMap.put("equipQua", "\\");
            eqMap.put("equipNum", "\\");
            eqMap.put("equipLeaseUnit", "\\");
            eqMap.put("equipUseUnit", "\\");
            eqMap.put("demolitionUnit", "\\");
            eqMap.put("testUnit", "\\");
            equipList.add(eqMap);
        } else {
            for (int i = 0; i < equipArray.size(); i++) {
                Map<String, Object> eqMap = new HashMap<String, Object>();
                JSONObject equipObject = equipArray.getJSONObject(i);
                eqMap.put("equipType", equipObject.getString("equipType"));
                eqMap.put("equipQua", equipObject.getString("equipQua"));
                eqMap.put("equipNum", equipObject.getString("equipNum"));
                eqMap.put("equipLeaseUnit", equipObject.getString("equipLeaseUnit"));
                eqMap.put("equipUseUnit", equipObject.getString("equipUseUnit"));
                eqMap.put("demolitionUnit", equipObject.getString("demolitionUnit"));
                eqMap.put("testUnit", equipObject.getString("testUnit"));
                equipList.add(eqMap);
            }
        }
        dataMap.put("equipList", equipList);

        //第一部分 安全综合评价 （一）模糊数学安全综合评价结果
        Fuzzyresult aqFuzzyResult = fuzzyresultMapper.selectInfoByCheckIdAndTypeAndNumber(checkId, 1, 1, -1);
        List<Double> allRiskList = new ArrayList<>();
        allRiskList.add(aqFuzzyResult.getRisk1Point());
        allRiskList.add(aqFuzzyResult.getRisk2Point());
        allRiskList.add(aqFuzzyResult.getRisk3Point());
        allRiskList.add(aqFuzzyResult.getRisk4Point());
        allRiskList.add(aqFuzzyResult.getRisk5Point());
        int allOverMaxIndex = allRiskList.lastIndexOf(Collections.max(allRiskList));
        String alloverRiskResult = "";
        switch (allOverMaxIndex) {
            case 0:
                alloverRiskResult = "\"安全\"";
                break;
            case 1:
                alloverRiskResult = "\"轻微风险\"";
                break;
            case 2:
                alloverRiskResult = "\"较大风险\"";
                break;
            case 3:
                alloverRiskResult = "\"重大风险\"";
                break;
            case 4:
                alloverRiskResult = "\"特别重大风险\"";
                break;
            default:
        }
        String fuzzyConclusion = "该项目安全实体风险等级" + "{" + "\"安全\"" + "\"轻微风险\"" +
                "\"较大风险\"" + "\"重大风险\"" + "\"特别重大风险\"" + "}" + "程度分别为{" + aqFuzzyResult.getRisk1Point() + "," + aqFuzzyResult.getRisk2Point() + ","
                + aqFuzzyResult.getRisk3Point() + "," + aqFuzzyResult.getRisk4Point() + "," + aqFuzzyResult.getRisk5Point() + "},依据最大隶属度原则,该项目风险状态隶属于" + alloverRiskResult;
        dataMap.put("fuzzyConclusion", fuzzyConclusion);
        try {
            HashMap<String, String> radarMap = new HashMap<>();
            Object[] radarData0 = new Object[]{aqFuzzyResult.getRisk1Point(), aqFuzzyResult.getRisk2Point(), aqFuzzyResult.getRisk3Point(), aqFuzzyResult.getRisk4Point(), aqFuzzyResult.getRisk5Point()};
            Object[] radarData1 = new Object[]{aqFuzzyResult.getRisk1Point(), "", "", "", ""};
            Object[] radarData2 = new Object[]{"", aqFuzzyResult.getRisk2Point(), "", "", ""};
            Object[] radarData3 = new Object[]{"", "", aqFuzzyResult.getRisk3Point(), "", ""};
            Object[] radarData4 = new Object[]{"", "", "", aqFuzzyResult.getRisk4Point(), ""};
            Object[] radarData5 = new Object[]{"", "", "", "", aqFuzzyResult.getRisk5Point()};
            Object[] radarData6 = new Object[]{"", "", "", "", ""};
            HashMap<String, Object> radarInfoMap = new HashMap<>();
            radarInfoMap.put("data0", radarData0);
            radarInfoMap.put("data1", radarData1);
            radarInfoMap.put("data2", radarData2);
            radarInfoMap.put("data3", radarData3);
            radarInfoMap.put("data4", radarData4);
            radarInfoMap.put("data5", radarData5);
            radarInfoMap.put("data6", radarData6);
            radarMap.put("dataSet", JSON.toJSONString(radarInfoMap));
            radarMap.put("height", "468");
            radarMap.put("width", "718");
            radarMap.put("index", "5");
            String radarPic = HttpUtil.post("http://localhost:3000/echarts", radarMap, "utf-8");
            dataMap.put("radarPic", radarPic.substring(22));
        } catch (Exception e) {
            e.printStackTrace();
        }
        //（二）、项目安全风险分布
        int allProblemNum = problemCollectDetailMapper.getAllNum(checkId);
        int txNum = problemCollectDetailMapper.getAllRiskPointCountByType(checkId, "提醒");
        int oneNum = problemCollectDetailMapper.getAllRiskPointCountByType(checkId, "1");
        int twoNum = problemCollectDetailMapper.getAllRiskPointCountByType(checkId, "2");
        int threeNum = problemCollectDetailMapper.getAllRiskPointCountByType(checkId, "3");
        int fourNum = problemCollectDetailMapper.getAllRiskPointCountByType(checkId, "4");
        dataMap.put("txNum", txNum);
        dataMap.put("oneNum", oneNum);
        dataMap.put("twoNum", twoNum);
        dataMap.put("threeNum", threeNum);
        dataMap.put("fourNum", fourNum);
        String txPercent = pointsCalculate.caculateToPercent(txNum, allProblemNum);
        String onePercent = pointsCalculate.caculateToPercent(oneNum, allProblemNum);
        String twoPercent = pointsCalculate.caculateToPercent(twoNum, allProblemNum);
        String threePercent = pointsCalculate.caculateToPercent(threeNum, allProblemNum);
        String fourPercent = pointsCalculate.caculateToPercent(fourNum, allProblemNum);
        dataMap.put("txPercent", txPercent);
        dataMap.put("onePercent", onePercent);
        dataMap.put("twoPercent", twoPercent);
        dataMap.put("threePercent", threePercent);
        dataMap.put("fourPercent", fourPercent);
        dataMap.put("allProblemNum", allProblemNum);
        try {
            HashMap<String, String> riskPieMap = new HashMap<>();
            Map<String, Object> riskPieMaps = new HashMap<>();
            Map<String, Object> riskPieMap0 = new HashMap<>();
            riskPieMap0.put("name", "提醒");
            riskPieMap0.put("y", txNum);
            riskPieMap0.put("sliced", true);
            riskPieMap0.put("color", "rgb(46,232,65)");
            Map<String, Object> riskPieMap1 = new HashMap<>();
            riskPieMap1.put("name", "特征值1");
            riskPieMap1.put("y", oneNum);
            riskPieMap1.put("sliced", true);
            riskPieMap1.put("color", "rgb(49,95,232)");
            Map<String, Object> riskPieMap2 = new HashMap<>();
            riskPieMap2.put("name", "特征值2");
            riskPieMap2.put("y", twoNum);
            riskPieMap2.put("sliced", true);
            riskPieMap2.put("color", "rgb(232,232,49)");
            Map<String, Object> riskPieMap3 = new HashMap<>();
            riskPieMap3.put("name", "特征值3");
            riskPieMap3.put("y", threeNum);
            riskPieMap3.put("sliced", true);
            riskPieMap3.put("color", "rgb(240,117,60)");
            Map<String, Object> riskPieMap4 = new HashMap<>();
            riskPieMap4.put("name", "特征值4");
            riskPieMap4.put("y", fourNum);
            riskPieMap4.put("sliced", true);
            riskPieMap4.put("color", "rgb(232,36,18)");
            Object[] riskPieInfo = new Object[]{riskPieMap0, riskPieMap1, riskPieMap2, riskPieMap3, riskPieMap4};
            riskPieMaps.put("data", riskPieInfo);
            riskPieMaps.put("title", "项目安全风险分布饼图");
            riskPieMap.put("dataSet", JSON.toJSONString(riskPieMaps));
            riskPieMap.put("height", "468");
            riskPieMap.put("width", "718");
            riskPieMap.put("index", "2");
            String riskPiePic = HttpUtil.post("http://localhost:3000/highcharts", riskPieMap, "utf-8");
            dataMap.put("riskPiePic", riskPiePic.substring(22));
        } catch (Exception e) {
            e.printStackTrace();
        }

        try {
            HashMap<String, String> riskBarMap = new HashMap<>();
            Map<String, Object> riskBarInfos = new HashMap<>();
            Map<String, Object> riskBarInfo0 = new HashMap<>();
            riskBarInfo0.put("name", "提醒");
            riskBarInfo0.put("color", "rgb(46,232,65)");
            riskBarInfo0.put("data", new Integer[]{txNum});
            Map<String, Object> riskBarInfo1 = new HashMap<>();
            riskBarInfo1.put("name", "特征值1");
            riskBarInfo1.put("color", "rgb(49,95,232)");
            riskBarInfo1.put("data", new Integer[]{oneNum});
            Map<String, Object> riskBarInfo2 = new HashMap<>();
            riskBarInfo2.put("name", "特征值2");
            riskBarInfo2.put("color", "rgb(232,232,49)");
            riskBarInfo2.put("data", new Integer[]{twoNum});
            Map<String, Object> riskBarInfo3 = new HashMap<>();
            riskBarInfo3.put("name", "特征值3");
            riskBarInfo3.put("color", "rgb(240,117,60)");
            riskBarInfo3.put("data", new Integer[]{threeNum});
            Map<String, Object> riskBarInfo4 = new HashMap<>();
            riskBarInfo4.put("name", "特征值4");
            riskBarInfo4.put("color", "rgb(232,36,18)");
            riskBarInfo4.put("data", new Integer[]{fourNum});
            Object[] riskBarInfo = new Object[]{riskBarInfo0, riskBarInfo1, riskBarInfo2, riskBarInfo3, riskBarInfo4};
            riskBarInfos.put("series", riskBarInfo);
            riskBarInfos.put("title", "项目安全风险分布直方图");
            riskBarMap.put("dataSet", JSON.toJSONString(riskBarInfos));
            riskBarMap.put("height", "468");
            riskBarMap.put("width", "718");
            riskBarMap.put("index", "3");
            String riskBarPic = HttpUtil.post("http://localhost:3000/highcharts", riskBarMap, "utf-8");
            dataMap.put("riskBarPic", riskBarPic.substring(22));
        } catch (Exception e) {
            e.printStackTrace();
        }

        //第一部分，（二）分项评估结果
        Integer taskId = contractchecktaskMapper.getTaskIdByCheckId(checkId);
        List<String> allBarCategories = new ArrayList<>();
        List<Double> allBarData0 = new ArrayList<>();
        List<Double> allBarData1 = new ArrayList<>();
        List<Double> allBarData2 = new ArrayList<>();

        List<String> aqResultBarCategories = new ArrayList<>();
        List<Integer> aqResultBarData0 = new ArrayList<>();
        List<Integer> aqResultBarData1 = new ArrayList<>();
        List<Double> aqResultBarData2 = new ArrayList<>();

        List<String> glResultBarCategories = new ArrayList<>();
        List<Integer> glResultBarData0 = new ArrayList<>();
        List<Integer> glResultBarData1 = new ArrayList<>();
        List<Double> glResultBarData2 = new ArrayList<>();

        String ZJname1 = "[1]";
        double allsecondPoint = 0;
        JSONArray ZJname1Array = JSONArray.parseArray(ZJname1);
        float allExtraPointFloat = problemCollectDetailMapper.getAllExtraPoint(checkId);
        double allExtraPoint = Double.valueOf(String.valueOf(allExtraPointFloat));
        double overAllPoint = 0;
        List<Object> part2List = new ArrayList<Object>();
        String Name1 = "";
        double allweight1 = 0;
        for (int i = 0; i < ZJname1Array.size(); i++) {
            double Tweight1 = 0;
            String weight1 = prefixsystemMapper.getWeight1ByName1(prefixsystemMapper.getName4ByName4Id(ZJname1Array.getIntValue(i)));
            Tweight1 = pointsCalculate.getPercentInstance(weight1);
            allweight1 += Tweight1;
        }
        for (int k = 0; k < ZJname1Array.size(); k++) {
            Map<String, Object> part2Map = new HashMap<String, Object>();
            List<Object> part2InnerList = new ArrayList<Object>();
            String pName1 = prefixsystemMapper.getName4ByName4Id(ZJname1Array.getIntValue(k));
            double Tweight1 = 0;
            String weight1 = prefixsystemMapper.getWeight1ByName1(pName1);
            Tweight1 = pointsCalculate.getPercentInstance(weight1);
            if (pName1.equals("安全检查")) {
                List<ProblemCollectDetail> list = problemCollectDetailMapper.getAllInfoByName1(checkId, pName1);
                dataMap.put("aqLever", pointsCalculate.getMaxRiskPoint(list));
                Name1 = "安全文明";
            } else if (pName1.equals("质量检查")) {
                List<ProblemCollectDetail> list = problemCollectDetailMapper.getAllInfoByName1(checkId, pName1);
                dataMap.put("zlLever", pointsCalculate.getMaxRiskPoint(list));
                Name1 = "质量风险";
            } else if (pName1.equals("管理行为")) {
                List<ProblemCollectDetail> list = problemCollectDetailMapper.getAllInfoByName1(checkId, pName1);
                dataMap.put("glLever", pointsCalculate.getMaxRiskPoint(list));
                Name1 = "管理行为";
            }
            part2Map.put("name1No", k + 1);
            part2Map.put("name1", Name1);
            List<Object> secondIdList = problemCollectDetailMapper.getSecondId(checkId, pName1);
            String secondIdInfo = JSON.toJSONString(secondIdList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
            JSONArray secondIdInfoArray = JSONArray.parseArray(secondIdInfo);
            double allweight2 = 0;
            for (int p = 0; p < secondIdInfoArray.size(); p++) {
                int allsecondId = secondIdInfoArray.getIntValue(p);
                String weight2 = prefixsystemMapper.getWeight3ByThirdId(allsecondId);
                double weight22 = pointsCalculate.getPercentInstance(weight2);
                allweight2 += weight22;
            }
            for (int u = 0; u < secondIdInfoArray.size(); u++) {
                int secondId = secondIdInfoArray.getIntValue(u);
                double weight222 = 0;
                String weight2 = prefixsystemMapper.getWeight3ByThirdId(secondId);
                weight222 = pointsCalculate.getPercentInstance(weight2);
                List<ProblemCollectDetail> fourthPoints = problemCollectDetailMapper.getFourthPoint(checkId, pName1, secondId);
                String fourthCalculateInfo = JSON.toJSONString(fourthPoints, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray fourthPointsCalculateArray = JSONArray.parseArray(fourthCalculateInfo);
                double point = 0;
                /*double allweight4 = 0;
                for (int v = 0; v < fourthPointsCalculateArray.size(); v++) {
                    JSONObject jsonObject = fourthPointsCalculateArray.getJSONObject(v);
                    double Tweight4 = 0;
                    int fourthId = jsonObject.getIntValue("fourthId");
                    String trueweight4 = prefixsystemMapper.getWeight3ByThirdId(fourthId);
                    Tweight4 = pointsCalculate.getPercentInstance(trueweight4);
                    allweight4 += Tweight4;
                }*/
                for (int j = 0; j < fourthPointsCalculateArray.size(); j++) {
                    Map<String, Object> part2InnerMap = new HashMap<String, Object>();
                    JSONObject part2InnerObject = fourthPointsCalculateArray.getJSONObject(j);
                    double allweight4 = 0;
                    List<ProblemCollectDetail> countFourthWeight = problemCollectDetailMapper.getAllFourthInfoMXTQ(checkId, part2InnerObject.getIntValue("thirdId"));
                    for (int v = 0; v < countFourthWeight.size(); v++) {
                        double Tweight4 = 0;
                        int fourthId = countFourthWeight.get(v).getFourthId();
                        String newWeight4 = editableweightpsMapper.getWeightByNumber(fourthId, taskId);
                        if (StringUtils.isNotBlank(newWeight4)) {
                            Tweight4 = pointsCalculate.getPercentInstance(newWeight4);
                        } else {
                            String trueweight4 = prefixsystemMapper.getWeight3ByThirdId(fourthId);
                            Tweight4 = pointsCalculate.getPercentInstance(trueweight4);
                        }
                        allweight4 += Tweight4;
                    }
                    part2InnerMap.put("pName4", part2InnerObject.getString("pName4"));
                    aqResultBarCategories.add(part2InnerObject.getString("pName4"));
                    double weight3 = 0;
                    double weight4 = 0;
                    int part2FourthId = part2InnerObject.getIntValue("fourthId");
                    int part2InnerProblemNum = problemCollectDetailMapper.getProblemNumByFourthId(checkId, part2FourthId);
                    int riskPointOver3Num = problemCollectDetailMapper.getProblemNumOver3(checkId, part2FourthId, type3List);
                    aqResultBarData0.add(part2InnerProblemNum);
                    aqResultBarData1.add(riskPointOver3Num);
                    part2InnerMap.put("problemNum", part2InnerProblemNum);
                    part2InnerMap.put("riskPointNum", riskPointOver3Num);
                    int part2ThirdId = part2InnerObject.getIntValue("thirdId");

                    //更改权重来源
                    String newWeight4 = editableweightpsMapper.getWeightByNumber(part2FourthId, taskId);
                    if (StringUtils.isNotBlank(newWeight4)) {
                        weight4 = pointsCalculate.getPercentInstance(newWeight4);
                    } else {
                        weight4 = pointsCalculate.getPercentInstance(part2InnerObject.getString("weight4"));
                    }

                    String newWeight3 = editableweightpsMapper.getWeightByNumber(part2ThirdId, taskId);
                    if (StringUtils.isNotBlank(newWeight3)) {
                        weight3 = pointsCalculate.getPercentInstance(newWeight3);
                    } else {
                        weight3 = pointsCalculate.getPercentInstance(part2InnerObject.getString("weight3"));
                    }

                    part2InnerMap.put("weight4", pointsCalculate.double2ToPercent(weight3, allweight4 / weight4));
                    List<ProblemCollectDetail> sixthPoints = problemCollectDetailMapper.getsixthPoints(checkId, part2FourthId);
                    String pointName6Info = JSON.toJSONString(sixthPoints, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                    JSONArray sixthPointsArray = JSONArray.parseArray(pointName6Info);
                    double calculatePoint6 = 0;
                    double calculatePoint66 = 0;
                    double calculateTruePoint = 0;
                    for (int y = 0; y < sixthPointsArray.size(); y++) {
                        JSONObject sixPointObject = sixthPointsArray.getJSONObject(y);
                        int deductSixthId = sixPointObject.getIntValue("sixthId");
                        float deductPointsSumFloat = problemCollectDetailMapper.getdeductSum(checkId, deductSixthId);
                        double deductPointsSum = Double.valueOf(String.valueOf(deductPointsSumFloat));
                        double truePoint = Double.parseDouble(sixPointObject.getString("point6"));
                        if (truePoint <= deductPointsSum) {
                            calculatePoint66 = 0;
                        } else {
                            calculatePoint66 = truePoint - deductPointsSum;
                        }
                        calculateTruePoint += truePoint;
                        calculatePoint6 += calculatePoint66;
                    }
                    double noProblemPoint = 0;
                    List<Object> noProblemSixthIdList = uncheckeditemsMapper.getNoProblemSixthId(checkId, part2InnerObject.getIntValue("fourthId"));
                    String noProblemSixthIdInfo = JSON.toJSONString(noProblemSixthIdList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                    JSONArray noProblemSixthArray = JSONArray.parseArray(noProblemSixthIdInfo);
                    for (int m = 0; m < noProblemSixthArray.size(); m++) {
                        int noProblemSixthId = noProblemSixthArray.getIntValue(m);
                        double noProblem = Double.parseDouble(prefixsystemMapper.getPoint4ByPoint4Id(noProblemSixthId));
                        noProblemPoint += noProblem;
                    }
                    double checkItemPoint = (calculatePoint6 + noProblemPoint) / (calculateTruePoint + noProblemPoint) * 100;
                    List<ProblemCollectDetail> checkItemCalcuList = problemCollectDetailMapper.getAllFourthInfo(checkId, part2FourthId);
                    String maxFourthRiskPoint = pointsCalculate.getMaxRiskPoint(checkItemCalcuList);
                    int maxFourthRiskPointNum = problemCollectDetailMapper.getRiskPointCount(checkId, part2FourthId, maxFourthRiskPoint);
                    double limitFourhPoint = Double.parseDouble((pointlimitMapper.getLimitPointByInfo(String.valueOf(maxFourthRiskPointNum), maxFourthRiskPoint)) == null ? "100" : pointlimitMapper.getLimitPointByInfo(String.valueOf(maxFourthRiskPointNum), maxFourthRiskPoint));
                    if (checkItemPoint > limitFourhPoint) {
                        checkItemPoint = limitFourhPoint;
                    }
                    String s = df.format(checkItemPoint);
                    aqResultBarData2.add(Double.parseDouble(s));
                    part2InnerMap.put("checkItemPoint", s);
                    int allPointSaveFourthPointCount = allpointsaveMapper.getAllPointCountByCheckId(checkId, part2FourthId);
                    if (allPointSaveFourthPointCount != 0) {
                        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
                        Date date1 = new Date(System.currentTimeMillis());
                        String lastEditTime = formatter.format(date1);
                        allpointsaveMapper.updateAllPoint(checkId, s, part2FourthId, lastEditTime);
                    } else {
                        Allpointsave allpointsave = new Allpointsave();
                        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
                        Date date1 = new Date(System.currentTimeMillis());
                        allpointsave.setNewCreateTime(formatter.format(date1));
                        allpointsave.setLastEditTime(formatter.format(date1));
                        allpointsave.setProjectId(projectId);
                        allpointsave.setCheckId(checkId);
                        allpointsave.setNumber(part2FourthId);
                        allpointsave.setPoint(s);
                        allpointsaveMapper.insert(allpointsave);
                    }
                    //point += checkItemPoint * weight3 / countFourthId;
                    point += checkItemPoint * weight3 / (allweight4 / weight4);
                    part2InnerList.add(part2InnerMap);
                }

                List<ProblemCollectDetail> noProblemItemList = problemCollectDetailMapper.getNoProblemItem(checkId, secondId);
                String noProblemCalculateInfo = JSON.toJSONString(noProblemItemList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray noProblemCalculateArray = JSONArray.parseArray(noProblemCalculateInfo);
                for (int j = 0; j < noProblemCalculateArray.size(); j++) {
                    Map<String, Object> part2InnerMap = new HashMap<String, Object>();
                    JSONObject part2InnerObject = noProblemCalculateArray.getJSONObject(j);
                    double allweight4 = 0;
                    List<ProblemCollectDetail> countFourthWeight = problemCollectDetailMapper.getAllFourthInfoMXTQ(checkId, part2InnerObject.getIntValue("thirdId"));
                    for (int v = 0; v < countFourthWeight.size(); v++) {
                        double Tweight4 = 0;
                        int fourthId = countFourthWeight.get(v).getFourthId();
                        String newWeight4 = editableweightpsMapper.getWeightByNumber(fourthId, taskId);
                        if (StringUtils.isBlank(newWeight4)) {
                            Tweight4 = pointsCalculate.getPercentInstance(newWeight4);
                        } else {
                            String trueweight4 = prefixsystemMapper.getWeight3ByThirdId(fourthId);
                            Tweight4 = pointsCalculate.getPercentInstance(trueweight4);
                        }
                        allweight4 += Tweight4;
                    }
                    part2InnerMap.put("pName4", "无问题项");
                    //aqResultBarCategories.add(part2InnerObject.getString("pName4"));
                    double weight3 = 0;
                    double weight4 = 0;
                    int part2FourthId = part2InnerObject.getIntValue("fourthId");
                    int part2InnerProblemNum = problemCollectDetailMapper.getProblemNumByFourthId(checkId, part2FourthId);
                    int riskPointOver3Num = problemCollectDetailMapper.getProblemNumOver3(checkId, part2FourthId, type3List);
                    aqResultBarData0.add(part2InnerProblemNum);
                    aqResultBarData1.add(riskPointOver3Num);
                    part2InnerMap.put("problemNum", part2InnerProblemNum);
                    part2InnerMap.put("riskPointNum", riskPointOver3Num);
                    int part2ThirdId = part2InnerObject.getIntValue("thirdId");

                    //更改权重来源
                    String newWeight4 = editableweightpsMapper.getWeightByNumber(part2FourthId, taskId);
                    if (StringUtils.isNotBlank(newWeight4)) {
                        weight4 = pointsCalculate.getPercentInstance(newWeight4);
                    } else {
                        weight4 = pointsCalculate.getPercentInstance(part2InnerObject.getString("weight4"));
                    }

                    String newWeight3 = editableweightpsMapper.getWeightByNumber(part2ThirdId, taskId);
                    if (StringUtils.isNotBlank(newWeight3)) {
                        weight3 = pointsCalculate.getPercentInstance(newWeight3);
                    } else {
                        weight3 = pointsCalculate.getPercentInstance(part2InnerObject.getString("weight3"));
                    }

                    part2InnerMap.put("weight4", pointsCalculate.double2ToPercent(weight3, allweight4 / weight4));
                    List<ProblemCollectDetail> sixthPoints = problemCollectDetailMapper.getsixthPoints(checkId, part2FourthId);
                    String pointName6Info = JSON.toJSONString(sixthPoints, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                    JSONArray sixthPointsArray = JSONArray.parseArray(pointName6Info);
                    double calculatePoint6 = 0;
                    double calculatePoint66 = 0;
                    double calculateTruePoint = 0;
                    for (int y = 0; y < sixthPointsArray.size(); y++) {
                        JSONObject sixPointObject = sixthPointsArray.getJSONObject(y);
                        int deductSixthId = sixPointObject.getIntValue("sixthId");
                        float deductPointsSumFloat = problemCollectDetailMapper.getdeductSum(checkId, deductSixthId);
                        double deductPointsSum = Double.valueOf(String.valueOf(deductPointsSumFloat));
                        double truePoint = Double.parseDouble(sixPointObject.getString("point6"));
                        if (truePoint <= deductPointsSum) {
                            calculatePoint66 = 0;
                        } else {
                            calculatePoint66 = truePoint - deductPointsSum;
                        }
                        calculateTruePoint += truePoint;
                        calculatePoint6 += calculatePoint66;
                    }
                    double noProblemPoint = 0;
                    List<Object> noProblemSixthIdList = uncheckeditemsMapper.getNoProblemSixthId(checkId, part2InnerObject.getIntValue("fourthId"));
                    String noProblemSixthIdInfo = JSON.toJSONString(noProblemSixthIdList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                    JSONArray noProblemSixthArray = JSONArray.parseArray(noProblemSixthIdInfo);
                    for (int m = 0; m < noProblemSixthArray.size(); m++) {
                        int noProblemSixthId = noProblemSixthArray.getIntValue(m);
                        double noProblem = Double.parseDouble(prefixsystemMapper.getPoint4ByPoint4Id(noProblemSixthId));
                        noProblemPoint += noProblem;
                    }
                    double checkItemPoint = (calculatePoint6 + noProblemPoint) / (calculateTruePoint + noProblemPoint) * 100;
                    List<ProblemCollectDetail> checkItemCalcuList = problemCollectDetailMapper.getAllFourthInfo(checkId, part2FourthId);
                    String maxFourthRiskPoint = pointsCalculate.getMaxRiskPoint(checkItemCalcuList);
                    int maxFourthRiskPointNum = problemCollectDetailMapper.getRiskPointCount(checkId, part2FourthId, maxFourthRiskPoint);
                    double limitFourhPoint = Double.parseDouble((pointlimitMapper.getLimitPointByInfo(String.valueOf(maxFourthRiskPointNum), maxFourthRiskPoint)) == null ? "100" : pointlimitMapper.getLimitPointByInfo(String.valueOf(maxFourthRiskPointNum), maxFourthRiskPoint));
                    if (checkItemPoint > limitFourhPoint) {
                        checkItemPoint = limitFourhPoint;
                    }
                    String s = df.format(checkItemPoint);
                    //aqResultBarData2.add(Double.parseDouble(s));
                    part2InnerMap.put("checkItemPoint", s);
                    /*int allPointSaveFourthPointCount = allpointsaveMapper.getAllPointCountByCheckId(checkId, part2FourthId);
                    if (allPointSaveFourthPointCount != 0) {
                        SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
                        Date date1 = new Date(System.currentTimeMillis());
                        String lastEditTime=formatter.format(date1);
                        allpointsaveMapper.updateAllPoint(checkId, s, part2FourthId,lastEditTime);
                    } else {
                        Allpointsave allpointsave = new Allpointsave();
                        SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
                        Date date1 = new Date(System.currentTimeMillis());
                        allpointsave.setNewCreateTime(formatter.format(date1));
                        allpointsave.setLastEditTime(formatter.format(date1));
                        allpointsave.setProjectId(projectId);
                        allpointsave.setCheckId(checkId);
                        allpointsave.setNumber(part2FourthId);
                        allpointsave.setPoint(s);
                        allpointsaveMapper.insert(allpointsave);
                    }*/
                    //point += checkItemPoint * weight3 / countFourthId;
                    //point += checkItemPoint * weight3 / (allweight4/weight4);
                    part2InnerList.add(part2InnerMap);
                }

                List<Object> getThirdId = problemCollectDetailMapper.getThirdId(checkId, pName1, secondId);
                String thirdIdInfo = JSON.toJSONString(getThirdId, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray thirdArray = JSONArray.parseArray(thirdIdInfo);

                double allweight3 = 0;
                for (int v = 0; v < thirdArray.size(); v++) {
                    double Tweight3 = 0;
                    int thirdId = thirdArray.getIntValue(v);
                    String newWeight3 = editableweightpsMapper.getWeightByNumber(thirdId, taskId);
                    if (StringUtils.isNotBlank(newWeight3)) {
                        Tweight3 = pointsCalculate.getPercentInstance(newWeight3);
                    } else {
                        String trueweight3 = prefixsystemMapper.getWeight3ByThirdId(thirdId);
                        Tweight3 = pointsCalculate.getPercentInstance(trueweight3);
                    }
                    allweight3 += Tweight3;
                }
                double thirdPoint = Double.parseDouble(df.format(point / allweight3));
                double percent2 = Double.parseDouble(df.format(weight222 / allweight2));
                double secondPoint = Double.parseDouble(df.format(thirdPoint * percent2));
                allsecondPoint += secondPoint;
            }
            if (pName1.equals("安全检查")) {
                dataMap.put("aqPoint", allsecondPoint);
            } else if (pName1.equals("质量检查")) {
                dataMap.put("zlPoint", allsecondPoint);
            } else if (pName1.equals("管理行为")) {
                dataMap.put("glPoint", allsecondPoint);
            }
            int firstPointCount = allpointsaveMapper.getAllPointCountByCheckId(checkId, 1);
            if (firstPointCount != 0) {
                SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
                Date date1 = new Date(System.currentTimeMillis());
                String lastEditTime = formatter.format(date1);
                allpointsaveMapper.updateAllPoint(checkId, df.format(allsecondPoint), 1, lastEditTime);
            } else {
                Allpointsave allpointsave = new Allpointsave();
                SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
                Date date1 = new Date(System.currentTimeMillis());
                allpointsave.setNewCreateTime(formatter.format(date1));
                allpointsave.setLastEditTime(formatter.format(date1));
                allpointsave.setCheckId(checkId);
                allpointsave.setNumber(1);
                allpointsave.setPoint(df.format(allsecondPoint));
                allpointsave.setProjectId(projectId);
                allpointsaveMapper.insert(allpointsave);
            }
            double trueWeight1 = Double.parseDouble(df.format(Tweight1 / allweight1));
            overAllPoint += Double.parseDouble(df.format(trueWeight1 * allsecondPoint));
            part2Map.put("point", allsecondPoint);
            part2Map.put("part2InnerList", part2InnerList);
            part2List.add(part2Map);
        }
        List<ProblemCollectDetail> overallList = problemCollectDetailMapper.getAllProblemCollectInfoByCheckId(checkId);
        ContractTaskProject contractTaskProjectRiskPoint = new ContractTaskProject();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
        Date date1 = new Date(System.currentTimeMillis());
        contractTaskProjectRiskPoint.setLastEditTime(formatter.format(date1));
        contractTaskProjectRiskPoint.setProjectId(projectId);
        contractTaskProjectRiskPoint.setLatestRiskLevel(pointsCalculate.getMaxRiskPoint(overallList));
        contracttaskprojectMapper.updateByPrimaryKeySelective(contractTaskProjectRiskPoint);
        ContractTaskProject newRiskList = contracttaskprojectMapper.selectByPrimaryKey(projectId);
        String finishTime = contractchecktaskMapper.getFinishTimeByCheckId(checkId);
        if (newRiskList.getCheckTime().equals("") || newRiskList.getCheckTime().compareTo(finishTime) <= 0) {
            try {
                ContractTaskProject contracttaskproject = new ContractTaskProject();
                contracttaskproject.setLastEditTime(formatter.format(date1));
                contracttaskproject.setProjectId(projectId);
                contracttaskproject.setLatestCheckTime(finishTime);
                contracttaskprojectMapper.updateByPrimaryKeySelective(contracttaskproject);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        dataMap.put("part2List", part2List);


        //综合评估结果
        List<Object> ZJList = new ArrayList<Object>();
        List<Integer> ZJaqFourthIdList = problemCollectDetailMapper.getAllFourthIdByCheckIdAndFirstId(checkId, 736);
        for (int j = 0; j < ZJaqFourthIdList.size(); j++) {
            double ZJallOverPoint = 0;
            allBarData2.add(allsecondPoint);
            Map<String, Object> ZJMap = new HashMap<>();
            int ZJpart2FourthId = ZJaqFourthIdList.get(j);
            ZJMap.put("No", j + 1);
            ZJMap.put("pName4", prefixsystemMapper.getName4ByName4Id(ZJpart2FourthId));
            allBarCategories.add(prefixsystemMapper.getName4ByName4Id(ZJpart2FourthId));
            glResultBarCategories.add(prefixsystemMapper.getName4ByName4Id(ZJpart2FourthId));
            int problemNum = problemCollectDetailMapper.getProblemNumByFourthId(checkId, ZJpart2FourthId);
            ZJMap.put("problemNum", problemNum);
            glResultBarData0.add(problemNum);
            int riskPoint = problemCollectDetailMapper.getRiskPointNumOver3ByFourthId(checkId, ZJpart2FourthId, type3List);
            ZJMap.put("riskPoint", riskPoint);
            glResultBarData1.add(riskPoint);
            List<ProblemCollectDetail> ZJsixthPoints = problemCollectDetailMapper.getZJsixthPoints(checkId, ZJpart2FourthId);
            String ZJpointName6Info = JSON.toJSONString(ZJsixthPoints, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
            JSONArray ZJsixthPointsArray = JSONArray.parseArray(ZJpointName6Info);
            double ZJcalculatePoint6 = 0;
            double ZJcalculatePoint66 = 0;
            double ZJcalculateTruePoint = 0;
            for (int y = 0; y < ZJsixthPointsArray.size(); y++) {
                JSONObject ZJsixPointObject = ZJsixthPointsArray.getJSONObject(y);
                int ZJdeductSixthId = ZJsixPointObject.getIntValue("sixthId");
                float ZJdeductPointsSumFloat = problemCollectDetailMapper.getdeductSum(checkId, ZJdeductSixthId);
                double ZJdeductPointsSum = Double.valueOf(String.valueOf(ZJdeductPointsSumFloat));
                double ZJtruePoint = Double.parseDouble(ZJsixPointObject.getString("point6"));
                if (ZJtruePoint <= ZJdeductPointsSum) {
                    ZJcalculatePoint66 = 0;
                } else {
                    ZJcalculatePoint66 = ZJtruePoint - ZJdeductPointsSum;
                }
                ZJcalculateTruePoint += ZJtruePoint;
                ZJcalculatePoint6 += ZJcalculatePoint66;
            }
            double ZJnoProblemPoint = 0;
            List<Object> ZJnoProblemSixthIdList = uncheckeditemsMapper.getNoProblemSixthId(checkId, ZJpart2FourthId);
            String ZJnoProblemSixthIdInfo = JSON.toJSONString(ZJnoProblemSixthIdList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
            JSONArray ZJnoProblemSixthArray = JSONArray.parseArray(ZJnoProblemSixthIdInfo);
            for (int m = 0; m < ZJnoProblemSixthArray.size(); m++) {
                int ZJnoProblemSixthId = ZJnoProblemSixthArray.getIntValue(m);
                double ZJnoProblem = Double.parseDouble(prefixsystemMapper.getPoint4ByPoint4Id(ZJnoProblemSixthId));
                ZJnoProblemPoint += ZJnoProblem;
            }
            double ZJcheckItemPoint = (ZJcalculatePoint6 + ZJnoProblemPoint) / (ZJcalculateTruePoint + ZJnoProblemPoint) * 100;
            List<ProblemCollectDetail> ZJcheckItemCalcuList = problemCollectDetailMapper.getAllFourthInfo(checkId, ZJpart2FourthId);
            String ZJmaxFourthRiskPoint = pointsCalculate.getMaxRiskPoint(ZJcheckItemCalcuList);
            int ZJmaxFourthRiskPointNum = problemCollectDetailMapper.getRiskPointCount(checkId, ZJpart2FourthId, ZJmaxFourthRiskPoint);
            double ZJlimitFourthPoint = Double.parseDouble((pointlimitMapper.getLimitPointByInfo(String.valueOf(ZJmaxFourthRiskPointNum), ZJmaxFourthRiskPoint)) == null ? "100" : pointlimitMapper.getLimitPointByInfo(String.valueOf(ZJmaxFourthRiskPointNum), ZJmaxFourthRiskPoint));
            if (ZJcheckItemPoint > ZJlimitFourthPoint) {
                ZJcheckItemPoint = ZJlimitFourthPoint;
            }
            String s = df.format(ZJcheckItemPoint);
            ZJMap.put("fourthPoint", s);
            ZJMap.put("aqAllPoint", df.format(allsecondPoint));
            ZJList.add(ZJMap);
            allBarData1.add(Double.parseDouble(s));
            glResultBarData2.add(Double.parseDouble(s));
            ZJallOverPoint = allsecondPoint * 0.7 + ZJcheckItemPoint * 0.3;
            String ZJallOver = df.format(ZJallOverPoint);
            allBarData0.add(Double.parseDouble(ZJallOver));
            ZJMap.put("allOverPoint", ZJallOver);
        }
        dataMap.put("ZJList", ZJList);
        //综合评估柱状图
        try {
            HashMap<String, String> allBarMap = new HashMap<>();
            Map<String, Object> allBarInfos = new HashMap<>();
            Map<String, Object> allBarInfo0 = new HashMap<>();
            allBarInfo0.put("name", "综合评分");
            allBarInfo0.put("color", "rgb(190,190,190)");
            allBarInfo0.put("data", allBarData0);
            Map<String, Object> allBarInfo1 = new HashMap<>();
            allBarInfo1.put("name", "管理行为（权重30%）");
            allBarInfo1.put("color", "rgb(232,137,31)");
            allBarInfo1.put("data", allBarData1);
            Map<String, Object> allBarInfo2 = new HashMap<>();
            allBarInfo2.put("name", "安全文明（权重70%）");
            allBarInfo2.put("color", "rgb(75,67,232)");
            allBarInfo2.put("data", allBarData2);
            Object[] riskBarInfo = new Object[]{allBarInfo0, allBarInfo1, allBarInfo2};
            allBarInfos.put("series", riskBarInfo);
            allBarInfos.put("title", "综合评估结果");
            allBarInfos.put("categories", allBarCategories);
            allBarMap.put("dataSet", JSON.toJSONString(allBarInfos));
            allBarMap.put("width", "718");
            allBarMap.put("height", "468");
            allBarMap.put("index", "8");
            String allBarPic = HttpUtil.post("http://localhost:3000/highcharts", allBarMap, "utf-8");
            dataMap.put("allBarPic", allBarPic.substring(22));
        } catch (Exception e) {
            e.printStackTrace();
        }
        //安全分项评估柱状图
        try {
            HashMap<String, String> aqResultBar = new HashMap<>();
            Map<String, Object> aqResultBarInfos = new HashMap<>();
            Map<String, Object> aqResultBarInfo0 = new HashMap<>();
            aqResultBarInfo0.put("name", "不符合项数量");
            aqResultBarInfo0.put("color", "rgb(75,67,232)");
            aqResultBarInfo0.put("data", aqResultBarData0);
            Map<String, Object> aqResultBarInfo1 = new HashMap<>();
            aqResultBarInfo1.put("name", "3级以上风险数量");
            aqResultBarInfo1.put("color", "red");
            aqResultBarInfo1.put("data", aqResultBarData1);
            Map<String, Object> aqResultBarInfo2 = new HashMap<>();
            aqResultBarInfo2.put("name", "分项得分");
            aqResultBarInfo2.put("color", "#00CD00");
            aqResultBarInfo2.put("data", aqResultBarData2);
            Object[] aqResultBarInfo = new Object[]{aqResultBarInfo0, aqResultBarInfo1, aqResultBarInfo2};
            aqResultBarInfos.put("series", aqResultBarInfo);
            aqResultBarInfos.put("title", "安全实体评估结果");
            aqResultBarInfos.put("subtitle", "安全文明得分:" + allsecondPoint);
            aqResultBarInfos.put("categories", aqResultBarCategories);
            aqResultBar.put("dataSet", JSON.toJSONString(aqResultBarInfos));
            aqResultBar.put("width", "718");
            aqResultBar.put("height", "468");
            aqResultBar.put("index", "1");
            String aqResultBarPic = HttpUtil.post("http://localhost:3000/highcharts", aqResultBar, "utf-8");
            dataMap.put("aqResultBarPic", aqResultBarPic.substring(22));
        } catch (Exception e) {
            e.printStackTrace();
        }

        //管理行为分项评估柱状图
        try {
            HashMap<String, String> glResultBar = new HashMap<>();
            Map<String, Object> glResultBarInfos = new HashMap<>();
            Map<String, Object> glResultBarInfo0 = new HashMap<>();
            glResultBarInfo0.put("name", "不符合项数量");
            glResultBarInfo0.put("color", "rgb(75,67,232)");
            glResultBarInfo0.put("data", glResultBarData0);
            Map<String, Object> glResultBarInfo1 = new HashMap<>();
            glResultBarInfo1.put("name", "3级以上风险数量");
            glResultBarInfo1.put("color", "red");
            glResultBarInfo1.put("data", glResultBarData1);
            Map<String, Object> glResultBarInfo2 = new HashMap<>();
            glResultBarInfo2.put("name", "分项得分");
            glResultBarInfo2.put("color", "#00CD00");
            glResultBarInfo2.put("data", glResultBarData2);
            Object[] glResultBarInfo = new Object[]{glResultBarInfo0, glResultBarInfo1, glResultBarInfo2};
            glResultBarInfos.put("series", glResultBarInfo);
            glResultBarInfos.put("title", "管理行为评估结果");
            glResultBarInfos.put("categories", glResultBarCategories);
            glResultBar.put("dataSet", JSON.toJSONString(glResultBarInfos));
            glResultBar.put("width", "718");
            glResultBar.put("height", "468");
            glResultBar.put("index", "4");
            String glResultBarPic = HttpUtil.post("http://localhost:3000/highcharts", glResultBar, "utf-8");
            dataMap.put("glResultBarPic", glResultBarPic.substring(22));
        } catch (Exception e) {
            e.printStackTrace();
        }

        //三、各分项安全风险情况及改进建议
        List<Object> aqFuzzyList = new ArrayList<>();
        List<Fuzzyresult> aqFuzzyResultInfo = fuzzyresultMapper.getAllFuzzyInfoByCheckIdAndTypeAndFirstId(checkId, 4, 1);
        for (int i = 0; i < aqFuzzyResultInfo.size(); i++) {
            Map<String, Object> aqFuzzyMap = new HashMap<>();
            aqFuzzyMap.put("secondIndicator", prefixsystemMapper.getName4ByName4Id(aqFuzzyResultInfo.get(i).getSecondId()));
            aqFuzzyMap.put("risk1Point", aqFuzzyResultInfo.get(i).getRisk1Point());
            aqFuzzyMap.put("risk2Point", aqFuzzyResultInfo.get(i).getRisk2Point());
            aqFuzzyMap.put("risk3Point", aqFuzzyResultInfo.get(i).getRisk3Point());
            aqFuzzyMap.put("risk4Point", aqFuzzyResultInfo.get(i).getRisk4Point());
            aqFuzzyMap.put("risk5Point", aqFuzzyResultInfo.get(i).getRisk5Point());
            aqFuzzyList.add(aqFuzzyMap);
        }
        dataMap.put("aqFuzzyList", aqFuzzyList);
        List<Object> aqSummaryList = new ArrayList<>();
        List<Summary> aqSummaryInfo = summaryMapper.getSummaryInfo(checkId, 1);
        for (int i = 0; i < aqSummaryInfo.size(); i++) {
            Map<String, Object> aqSummaryMap = new HashMap<>();
            aqSummaryMap.put("No", i + 1);
            aqSummaryMap.put("pName4", prefixsystemMapper.getName4ByName4Id(aqSummaryInfo.get(i).getFourthId()));
            aqSummaryMap.put("summary", aqSummaryInfo.get(i).getSummary());
            Fuzzyresult fuzzyResult = fuzzyresultMapper.selectInfoByCheckIdAndTypeAndNumber(checkId, 4, 1, aqSummaryInfo.get(i).getFourthId());
            try {
                HashMap<String, String> radarMap = new HashMap<>();
                Object[] radarData0 = new Object[]{fuzzyResult.getRisk1Point(), fuzzyResult.getRisk2Point(), fuzzyResult.getRisk3Point(), fuzzyResult.getRisk4Point(), fuzzyResult.getRisk5Point()};
                Object[] radarData1 = new Object[]{fuzzyResult.getRisk1Point(), "", "", "", ""};
                Object[] radarData2 = new Object[]{"", fuzzyResult.getRisk2Point(), "", "", ""};
                Object[] radarData3 = new Object[]{"", "", fuzzyResult.getRisk3Point(), "", ""};
                Object[] radarData4 = new Object[]{"", "", "", fuzzyResult.getRisk4Point(), ""};
                Object[] radarData5 = new Object[]{"", "", "", "", fuzzyResult.getRisk5Point()};
                Object[] radarData6 = new Object[]{"", "", "", "", ""};
                HashMap<String, Object> radarInfoMap = new HashMap<>();
                radarInfoMap.put("data0", radarData0);
                radarInfoMap.put("data1", radarData1);
                radarInfoMap.put("data2", radarData2);
                radarInfoMap.put("data3", radarData3);
                radarInfoMap.put("data4", radarData4);
                radarInfoMap.put("data5", radarData5);
                radarInfoMap.put("data6", radarData6);
                radarMap.put("dataSet", JSON.toJSONString(radarInfoMap));
                radarMap.put("height", "468");
                radarMap.put("width", "718");
                radarMap.put("index", "5");
                String radarPic = HttpUtil.post("http://localhost:3000/echarts", radarMap, "utf-8");
                aqSummaryMap.put("radarPic", radarPic.substring(22));
            } catch (Exception e) {
                e.printStackTrace();
            }
            aqSummaryList.add(aqSummaryMap);
        }
        dataMap.put("aqSummaryList", aqSummaryList);
        List<Object> glSummaryList = new ArrayList<>();
        List<Summary> glSummaryInfo = summaryMapper.getSummaryInfo(checkId, 736);
        for (int i = 0; i < glSummaryInfo.size(); i++) {
            Map<String, Object> glSummaryMap = new HashMap<>();
            glSummaryMap.put("No", i + 1);
            glSummaryMap.put("pName4", prefixsystemMapper.getName4ByName4Id(glSummaryInfo.get(i).getFourthId()));
            glSummaryMap.put("summary", glSummaryInfo.get(i).getSummary());
            glSummaryList.add(glSummaryMap);
        }
        dataMap.put("glSummaryList", glSummaryList);

        //第二部分 不符合项清单
        List<ProblemCollectDetail> problemList = problemCollectDetailMapper.getAllProblemCollectInfoByCheckId(checkId);
        List<Object> section22List = new ArrayList<Object>();
        for (int p = 0; p < problemList.size(); p++) {
            Map<String, Object> problemListMap = new HashMap<String, Object>();
            problemListMap.put("No", p + 1);
            if (problemList.get(p).getSecondId() == 1385) {
                problemListMap.put("pName4", problemList.get(p).getpName4() + "(" + problemList.get(p).getpName3() + ")");
            } else {
                problemListMap.put("pName4", problemList.get(p).getpName4());
            }
            if (problemList.get(p).getIsRemark().equals("N")) {
                problemListMap.put("problemDescription", problemList.get(p).getProblemDescription());
            } else if (problemList.get(p).getIsRemark().equals("Y")) {
                problemListMap.put("problemDescription", problemList.get(p).getRemark());
            }
            problemListMap.put("riskPoint", problemList.get(p).getRiskPoint());
            section22List.add(problemListMap);
        }
        dataMap.put("section22List", section22List);

        //第三部分，安全问题各分项检查情况
        List<Object> pName1Info = problemCollectDetailMapper.getAllName1Id(checkId);
        String name1 = JSON.toJSONString(pName1Info, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        JSONArray name1Array = JSONArray.parseArray(name1);
        String section2pName1 = "";
        List<Object> section2List = new ArrayList<Object>();
        for (int b = 0; b < name1Array.size(); b++) {
            Map<String, Object> section2Name1Map = new HashMap<String, Object>();
            List<Object> section2name1List = new ArrayList<Object>();
            String section2name1 = prefixsystemMapper.getName4ByName4Id(name1Array.getIntValue(b));
            if (section2name1.equals("安全检查")) {
                section2pName1 = "安全问题";
            } else if (section2name1.equals("质量检查")) {
                section2pName1 = "质量问题";
            } else if (section2name1.equals("管理行为")) {
                section2pName1 = "管理体系及管理动作";
            }
            section2Name1Map.put("section2pName1", section2pName1);
            List<Object> section2Name4Info = problemCollectDetailMapper.getAllName4ByName1(checkId, section2name1);
            String section2Name44 = JSON.toJSONString(section2Name4Info, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
            JSONArray section2Name4Array = JSONArray.parseArray(section2Name44);
            for (int w = 0; w < section2Name4Array.size(); w++) {
                Map<String, Object> section2Name4Map = new HashMap<String, Object>();
                List<Object> section2Name4List = new ArrayList<Object>();
                int section2Name4Id = section2Name4Array.getIntValue(w);
                String section2Name4 = prefixsystemMapper.getName4ByName4Id(section2Name4Id);
                List<ProblemCollectDetail> section2Name6Info = problemCollectDetailMapper.getAllName6InfoByName4(checkId, section2Name4Id, section2name1);
                String section2Name66 = JSON.toJSONString(section2Name6Info, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray section2Name6Array = JSONArray.parseArray(section2Name66);
                for (int c = 0; c < section2Name6Array.size(); c++) {
                    Map<String, Object> section2Name6Map = new HashMap<String, Object>();
                    List<Object> picList = new ArrayList<Object>();
                    JSONObject section2Name6Object = section2Name6Array.getJSONObject(c);
                    section2Name6Map.put("section2pName6No", c + 1);
                    section2Name6Map.put("section2pName6", section2Name6Object.getString("pName6"));
                    section2Name6Map.put("section2pName5", section2Name6Object.getString("pName5"));
                    section2Name6Map.put("section2RiskLevel", section2Name6Object.getString("riskPoint"));
                    section2Name6Map.put("section2CheckPart", section2Name6Object.getString("checkPart"));
                    section2Name6Map.put("section2ProblemNum", section2Name6Object.getString("problemQua"));
                    if (section2Name6Object.getString("isRemark").equals("N")) {
                        section2Name6Map.put("section2problemDescription", section2Name6Object.getString("problemDescription"));
                    } else if (section2Name6Object.getString("isRemark").equals("Y")) {
                        section2Name6Map.put("section2problemDescription", section2Name6Object.getString("remark"));
                    }
                    section2Name6Map.put("section2normsProvison", section2Name6Object.getString("normsProvison"));
                    section2Name6Map.put("section2suggestion", section2Name6Object.getString("suggestion"));
                    String section2picPath = section2Name6Object.getString("picPath");
                    String picName = section2Name6Object.getString("picName");
                    JSONArray ja = JSONArray.parseArray(picName);
                    if (ja.size() == 0) {
                        //String s = MDoc.getImageStr("C:\\Users\\96500\\Desktop\\20190329183836002.png");
                        String s = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                        picList.add(s);
                    } else {
                        for (int o = 0; o < ja.size(); o++) {
                            String s="";
                            if( "prod".equals(profiles.getActives()) ){
                                s = MDoc.getImageStr(section2picPath + ja.getString(o));
                            }

                            //String s = MDoc.getImageStr("C:\\Users\\96500\\Desktop\\20190329183836002.png");
                            picList.add(s);
                        }
                    }
                    section2Name6Map.put("picList", picList);
                    section2Name4List.add(section2Name6Map);

                }
                section2Name4Map.put("section2pName4", section2Name4);
                section2Name4Map.put("section2Name4List", section2Name4List);
                section2name1List.add(section2Name4Map);
            }
            section2Name1Map.put("section2Name1List", section2name1List);
            section2List.add(section2Name1Map);
        }
        dataMap.put("section2List", section2List);
        MDoc mdoc = new MDoc();
        String path = FileUtil.getServerFolderPath();
        File f1 = new File(path, "doc");
        if (!f1.exists()) {
            f1.mkdirs();
        }
        mdoc.createDoc(dataMap, path + "\\doc\\" + projectObject.getString("projectName").replace('#', '号') + "安全可视化报告" + fileName + ".doc", "ftl\\aqVisible.ftl");
        MDoc.docToDocx("D:\\whutServer\\apache-tomcat-8.5.41\\webapps\\ROOT\\doc\\" + projectObject.getString("projectName").replace('#', '号') + "安全可视化报告" + fileName + ".doc", "D:\\whutServer\\apache-tomcat-8.5.41\\webapps\\ROOT\\doc\\" + projectObject.getString("projectName").replace('#', '号') + "安全可视化报告" + fileName + ".doc");
        String result = urlProperties.getAddress() + "/doc/" + projectObject.getString("projectName").replace('#', '号') + "安全可视化报告" + fileName + ".doc";
        return result;
    }

    @Override
    public String getVisualizationReport2(int checkId, int projectId) throws UnsupportedEncodingException {
        DecimalFormat df = new DecimalFormat("0.00");
        Map<String, Object> dataMap = new HashMap<String, Object>();
        Date date = new Date();
        DateFormat d1 = new SimpleDateFormat("yyyyMMddhhmmss");
        DateFormat d2 = new SimpleDateFormat("yyyy");
        DateFormat d3 = new SimpleDateFormat("MM");
        DateFormat d4 = new SimpleDateFormat("dd");
        String day = d4.format(date);
        String month = d3.format(date);
        String year = d2.format(date);
        String fileName = d1.format(date);
        dataMap.put("day", day);
        dataMap.put("month", month);
        dataMap.put("year", year);
        List<String> type3List = new ArrayList<String>();
        type3List.add("2");
        type3List.add("3");
        type3List.add("4");
        //工程概况部分，来自ctp的工程信息
        List<ContractTaskProject> projectList = contracttaskprojectMapper.selectAllByCheckId(projectId);
        String project = JSON.toJSONString(projectList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        JSONArray projectArray = JSONArray.parseArray(project);
        JSONObject projectObject = projectArray.getJSONObject(0);
        dataMap.put("projectName", projectObject.getString("projectName"));
        dataMap.put("projectAddress", projectObject.getString("area"));
        dataMap.put("jsUnit", projectObject.getString("jsUnit"));
        dataMap.put("jlUnit", projectObject.getString("jlUnit"));
        dataMap.put("sgUnit", projectObject.getString("sgUnit"));
        dataMap.put("projectType", projectObject.getString("projectType"));
        dataMap.put("remark", projectObject.getString("remark"));
        dataMap.put("projectDescription", projectObject.getString("projectDescription"));
        String js = projectObject.getString("jsUniter");
        String jl = projectObject.getString("jlUniter");
        String sg = projectObject.getString("manager");
        dataMap.put("jsUniter", js);
        dataMap.put("jlUniter", jl);
        dataMap.put("sgUniter", sg);

        //项目质量隐患分布/*/                                                                                                                                                                                                                   */
        int allProblemNum = problemCollectDetailMapper.getAllNum(checkId);
        int txNum = problemCollectDetailMapper.getAllRiskPointCountByType(checkId, "提醒");
        int oneNum = problemCollectDetailMapper.getAllRiskPointCountByType(checkId, "1");
        int twoNum = problemCollectDetailMapper.getAllRiskPointCountByType(checkId, "2");
        int threeNum = problemCollectDetailMapper.getAllRiskPointCountByType(checkId, "3");
        int fourNum = problemCollectDetailMapper.getAllRiskPointCountByType(checkId, "4");
        dataMap.put("txNum", txNum);
        dataMap.put("oneNum", oneNum);
        dataMap.put("twoNum", twoNum);
        dataMap.put("threeNum", threeNum);
        dataMap.put("fourNum", fourNum);
        String txPercent = pointsCalculate.caculateToPercent(txNum, allProblemNum);
        String onePercent = pointsCalculate.caculateToPercent(oneNum, allProblemNum);
        String twoPercent = pointsCalculate.caculateToPercent(twoNum, allProblemNum);
        String threePercent = pointsCalculate.caculateToPercent(threeNum, allProblemNum);
        String fourPercent = pointsCalculate.caculateToPercent(fourNum, allProblemNum);
        dataMap.put("txPercent", txPercent);
        dataMap.put("onePercent", onePercent);
        dataMap.put("twoPercent", twoPercent);
        dataMap.put("threePercent", threePercent);
        dataMap.put("fourPercent", fourPercent);
        dataMap.put("allProblemNum", allProblemNum);
        try {
            HashMap<String, String> riskPieMap = new HashMap<>();
            Map<String, Object> riskPieMaps = new HashMap<>();
            Map<String, Object> riskPieMap0 = new HashMap<>();
            riskPieMap0.put("name", "提醒");
            riskPieMap0.put("y", txNum);
            riskPieMap0.put("sliced", true);
            riskPieMap0.put("color", "rgb(46,232,65)");
            Map<String, Object> riskPieMap1 = new HashMap<>();
            riskPieMap1.put("name", "特征值1");
            riskPieMap1.put("y", oneNum);
            riskPieMap1.put("sliced", true);
            riskPieMap1.put("color", "rgb(49，95，232)");
            Map<String, Object> riskPieMap2 = new HashMap<>();
            riskPieMap2.put("name", "特征值2");
            riskPieMap2.put("y", twoNum);
            riskPieMap2.put("sliced", true);
            riskPieMap2.put("color", "rgb(232,232,232)");
            Map<String, Object> riskPieMap3 = new HashMap<>();
            riskPieMap3.put("name", "特征值3");
            riskPieMap3.put("y", threeNum);
            riskPieMap3.put("sliced", true);
            riskPieMap3.put("color", "rgb(240,117,60)");
            Map<String, Object> riskPieMap4 = new HashMap<>();
            riskPieMap4.put("name", "特征值4");
            riskPieMap4.put("y", fourNum);
            riskPieMap4.put("sliced", true);
            riskPieMap4.put("color", "rgb(232,36,18)");
            Object[] riskPieInfo = new Object[]{riskPieMap0, riskPieMap1, riskPieMap2, riskPieMap3, riskPieMap4};
            riskPieMaps.put("data", riskPieInfo);
            riskPieMaps.put("title", "项目质量隐患分布饼图");
            riskPieMap.put("dataSet", JSON.toJSONString(riskPieMaps));
            riskPieMap.put("width", "718");
            riskPieMap.put("height", "468");
            riskPieMap.put("index", "2");
            String riskPiePic = HttpUtil.post("http://localhost:3000/highcharts", riskPieMap, "utf-8");
            dataMap.put("riskPiePic", riskPiePic.substring(22));
        } catch (Exception e) {
            e.printStackTrace();
        }

        try {
            HashMap<String, String> riskBarMap = new HashMap<>();
            Map<String, Object> riskBarInfos = new HashMap<>();
            Map<String, Object> riskBarInfo0 = new HashMap<>();
            riskBarInfo0.put("name", "提醒");
            riskBarInfo0.put("color", "rgb(46,232,65)");
            riskBarInfo0.put("data", new Integer[]{txNum});
            Map<String, Object> riskBarInfo1 = new HashMap<>();
            riskBarInfo1.put("name", "特征值1");
            riskBarInfo1.put("color", "rgb(49,95,232)");
            riskBarInfo1.put("data", new Integer[]{oneNum});
            Map<String, Object> riskBarInfo2 = new HashMap<>();
            riskBarInfo2.put("name", "特征值2");
            riskBarInfo2.put("color", "rgb(232,232,49)");
            riskBarInfo2.put("data", new Integer[]{twoNum});
            Map<String, Object> riskBarInfo3 = new HashMap<>();
            riskBarInfo3.put("name", "特征值3");
            riskBarInfo3.put("color", "rgb(240,117,60)");
            riskBarInfo3.put("data", new Integer[]{threeNum});
            Map<String, Object> riskBarInfo4 = new HashMap<>();
            riskBarInfo4.put("name", "特征值4");
            riskBarInfo4.put("color", "rgb(232,36,18)");
            riskBarInfo4.put("data", new Integer[]{fourNum});
            Object[] riskBarInfo = new Object[]{riskBarInfo0, riskBarInfo1, riskBarInfo2, riskBarInfo3, riskBarInfo4};
            riskBarInfos.put("series", riskBarInfo);
            riskBarInfos.put("title", "项目质量隐患分布直方图");
            riskBarMap.put("dataSet", JSON.toJSONString(riskBarInfos));
            riskBarMap.put("width", "718");
            riskBarMap.put("height", "468");
            riskBarMap.put("index", "3");
            String riskBarPic = HttpUtil.post("http://localhost:3000/highcharts", riskBarMap, "utf-8");
            dataMap.put("riskBarPic", riskBarPic.substring(22));
        } catch (Exception e) {
            e.printStackTrace();
        }

        //实测实量分项结果
        List<String> scslBarCategories = new ArrayList<>();
        List<Double> scslBarData0 = new ArrayList<>();
        int scslNum = measuretablerecordMapper.getAllNumByCheckId(checkId);
        dataMap.put("scslNum", scslNum);
        int scslQuaNum = measuretablerecordMapper.getAllQuaNumByCheckId(checkId);
        String scslPoint = pointsCalculate.caculateToPercent(scslQuaNum, scslNum);
        dataMap.put("scslPoint", scslPoint);
        List<Measuretablerecord> measuretablerecords = measuretablerecordMapper.getTableData(checkId);
        List<Object> scslList = new ArrayList<>();
        if (scslNum == 0) {
            Map<String, Object> scslMap = new HashMap<>();
            scslMap.put("no", "/");
            scslMap.put("pName3", "/");
            scslMap.put("pName4", "/");
            scslBarCategories.add("未测量");
            scslMap.put("totalQualifiedRate", "/");
            scslBarData0.add(0.0);
            scslMap.put("reserve1", "/");
            scslMap.put("remark", "/");
            scslList.add(scslMap);
        } else {
            for (int i = 0; i < measuretablerecords.size(); i++) {
                Map<String, Object> scslMap = new HashMap<>();
                scslMap.put("no", i + 1);
                scslMap.put("pName3", measuretablerecords.get(i).getReserve2() == null ? "" : measuretablerecords.get(i).getReserve2());
                scslMap.put("pName4", measuretablerecords.get(i).getMeasureTableName());
                scslBarCategories.add(measuretablerecords.get(i).getMeasureTableName());
                scslMap.put("totalQualifiedRate", measuretablerecords.get(i).getTotalQualifiedRate());
                scslBarData0.add(pointsCalculate.getPercentInstance(measuretablerecords.get(i).getTotalQualifiedRate()));
                scslMap.put("reserve1", measuretablerecords.get(i).getReserve1() == null ? "" : measuretablerecords.get(i).getReserve1());
                scslMap.put("remark", measuretablerecords.get(i).getMeasureTableName() + "共实测" + measuretablerecords.get(i).getTotalPointNumber() + "个点,其中" + (measuretablerecords.get(i).getTotalPointNumber() - measuretablerecords.get(i).getQualifiedPointNumber()) + "个点不合格。");
                scslList.add(scslMap);
            }
        }
        //实测实量合格率直方图
        try {
            HashMap<String, String> scslBarMap = new HashMap<>();
            Map<String, Object> scslBarInfos = new HashMap<>();
            Map<String, Object> scslBarInfo0 = new HashMap<>();
            scslBarInfo0.put("name", "合格率");
            scslBarInfo0.put("color", "rgb(49,95,232)");
            scslBarInfo0.put("data", scslBarData0);
            Object[] scslBarInfo = new Object[]{scslBarInfo0};
            scslBarInfos.put("series", scslBarInfo);
            scslBarInfos.put("categories", scslBarCategories);
            scslBarInfos.put("title", "实测实量合格率直方图");
            scslBarMap.put("dataSet", JSON.toJSONString(scslBarInfos));
            scslBarMap.put("width", "718");
            scslBarMap.put("height", "468");
            scslBarMap.put("index", "6");
            String scslBarPic = HttpUtil.post("http://localhost:3000/highcharts", scslBarMap, "utf-8");
            dataMap.put("scslBarPic", scslBarPic.substring(22));
        } catch (Exception e) {
            e.printStackTrace();
        }

        //分数计算
        Integer taskId = contractchecktaskMapper.getTaskIdByCheckId(checkId);
        List<ProblemCollectDetail> thirdIdProblemDetail = problemCollectDetailMapper.getAllThirdInfoMXTQ(checkId);
        for (int i = 0; i < thirdIdProblemDetail.size(); i++) {
            double point3 = 0;
            int thirdId = thirdIdProblemDetail.get(i).getThirdId();
            List<ProblemCollectDetail> fourthIdProblemDetail = problemCollectDetailMapper.getAllFourthInfoMXTQ(checkId, thirdId);
            String fourthCalculateInfo = JSON.toJSONString(fourthIdProblemDetail, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
            JSONArray fourthPointsCalculateArray = JSONArray.parseArray(fourthCalculateInfo);
           /* double allweight4 = 0;
            for (int v = 0; v < fourthPointsCalculateArray.size(); v++) {
                JSONObject jsonObject = fourthPointsCalculateArray.getJSONObject(v);
                double Tweight4 = 0;
                int fourthId = jsonObject.getIntValue("fourthId");
                String trueweight4 = prefixsystemMapper.getWeight3ByThirdId(fourthId);
                Tweight4 = pointsCalculate.getPercentInstance(trueweight4);
                allweight4 += Tweight4;
            }*/
            for (int j = 0; j < fourthPointsCalculateArray.size(); j++) {
                JSONObject part2InnerObject = fourthPointsCalculateArray.getJSONObject(j);
                double allweight4 = 0;
                List<ProblemCollectDetail> countFourthWeight = problemCollectDetailMapper.getAllFourthInfoMXTQ(checkId, part2InnerObject.getIntValue("thirdId"));
                for (int v = 0; v < countFourthWeight.size(); v++) {
                    double Tweight4 = 0;
                    int fourthId = countFourthWeight.get(v).getFourthId();
                    String newWeight4 = editableweightpsMapper.getWeightByNumber(fourthId, taskId);
                    if (StringUtils.isNotBlank(newWeight4)) {
                        Tweight4 = pointsCalculate.getPercentInstance(newWeight4);
                    } else {
                        String trueweight4 = prefixsystemMapper.getWeight3ByThirdId(fourthId);
                        Tweight4 = pointsCalculate.getPercentInstance(trueweight4);
                    }
                    allweight4 += Tweight4;
                }
                double weight3 = 0;
                double weight4 = 0;
                int part2FourthId = part2InnerObject.getIntValue("fourthId");
                int part2ThirdId = part2InnerObject.getIntValue("thirdId");
                //更改权重来源
                String newWeight44 = editableweightpsMapper.getWeightByNumber(part2FourthId, taskId);
                if (StringUtils.isNotBlank(newWeight44)) {
                    weight4 = pointsCalculate.getPercentInstance(newWeight44);
                } else {
                    weight4 = pointsCalculate.getPercentInstance(part2InnerObject.getString("weight4"));
                }

                String newWeight33 = editableweightpsMapper.getWeightByNumber(part2ThirdId, taskId);
                if (StringUtils.isNotBlank(newWeight33)) {
                    weight3 = pointsCalculate.getPercentInstance(newWeight33);
                } else {
                    weight3 = pointsCalculate.getPercentInstance(part2InnerObject.getString("weight3"));
                }

                List<ProblemCollectDetail> sixthPoints = problemCollectDetailMapper.getsixthPoints(checkId, part2FourthId);
                String pointName6Info = JSON.toJSONString(sixthPoints, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray sixthPointsArray = JSONArray.parseArray(pointName6Info);
                double calculatePoint6 = 0;
                double calculatePoint66 = 0;
                double calculateTruePoint = 0;
                List<Object> allSixthList = new ArrayList<>();
                for (int y = 0; y < sixthPointsArray.size(); y++) {
                    Map<String, Object> allSixMap = new HashMap<>();
                    JSONObject sixPointObject = sixthPointsArray.getJSONObject(y);
                    allSixMap.put("pName6", sixPointObject.getString("pName6"));
                    int deductSixthId = sixPointObject.getIntValue("sixthId");
                    float deductPointsSumFloat = problemCollectDetailMapper.getdeductSum(checkId, deductSixthId);
                    double deductPointsSum = Double.valueOf(String.valueOf(deductPointsSumFloat));
                    double truePoint = Double.parseDouble(sixPointObject.getString("point6"));
                    allSixMap.put("duePoint", truePoint);
                    allSixMap.put("deductPoint", deductPointsSum);
                    allSixthList.add(allSixMap);
                    if (truePoint <= deductPointsSum) {
                        calculatePoint66 = 0;
                    } else {
                        calculatePoint66 = truePoint - deductPointsSum;
                    }
                    calculateTruePoint += truePoint;
                    calculatePoint6 += calculatePoint66;
                }
                double noProblemPoint = 0;
                List<Object> noProblemSixthIdList = uncheckeditemsMapper.getNoProblemSixthId(checkId, part2InnerObject.getIntValue("fourthId"));
                String noProblemSixthIdInfo = JSON.toJSONString(noProblemSixthIdList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray noProblemSixthArray = JSONArray.parseArray(noProblemSixthIdInfo);
                for (int m = 0; m < noProblemSixthArray.size(); m++) {
                    Map<String, Object> allSixMap = new HashMap<>();
                    int noProblemSixthId = noProblemSixthArray.getIntValue(m);
                    allSixMap.put("pName6", prefixsystemMapper.getName4ByName4Id(noProblemSixthId));
                    allSixMap.put("duePoint", prefixsystemMapper.getPoint4ByPoint4Id(noProblemSixthId));
                    allSixMap.put("deductPoint", 0);
                    allSixthList.add(allSixMap);
                    double noProblem = Double.parseDouble(prefixsystemMapper.getPoint4ByPoint4Id(noProblemSixthId));
                    noProblemPoint += noProblem;
                }
                List<Integer> wsjList = prefixsystemMapper.getWSJList(checkId, part2InnerObject.getIntValue("fourthId"));
                for (int g = 0; g < wsjList.size(); g++) {
                    Map<String, Object> allSixMap = new HashMap<>();
                    int wsjSixthId = wsjList.get(g);
                    allSixMap.put("pName6", prefixsystemMapper.getName4ByName4Id(wsjSixthId));
                    allSixMap.put("duePoint", prefixsystemMapper.getPoint4ByPoint4Id(wsjSixthId));
                    allSixMap.put("deductPoint", "未涉及");
                    allSixthList.add(allSixMap);
                }
                System.out.println("第六级扣过的分数总分:" + calculatePoint6 + "没有问题的总分:" + noProblemPoint + "第六级总分:" + calculateTruePoint);
                double checkItemPoint = (calculatePoint6 + noProblemPoint) / (calculateTruePoint + noProblemPoint) * 100;
                point3 += checkItemPoint * (weight4 / allweight4);
                List<ProblemCollectDetail> checkItemCalcuList = problemCollectDetailMapper.getAllFourthInfo(checkId, part2FourthId);
                String maxFourthRiskPoint = pointsCalculate.getMaxRiskPoint(checkItemCalcuList);
                int maxFourthRiskPointNum = problemCollectDetailMapper.getRiskPointCount(checkId, part2FourthId, maxFourthRiskPoint);
                double limitFourhPoint = Double.parseDouble((pointlimitMapper.getLimitPointByInfo(String.valueOf(maxFourthRiskPointNum), maxFourthRiskPoint)) == null ? "100" : pointlimitMapper.getLimitPointByInfo(String.valueOf(maxFourthRiskPointNum), maxFourthRiskPoint));
                if (checkItemPoint > limitFourhPoint) {
                    checkItemPoint = limitFourhPoint;
                }
                String s = df.format(checkItemPoint);
                int allPointSaveFourthPointCount = allpointsaveMapper.getAllPointCountByCheckId(checkId, part2FourthId);
                if (allPointSaveFourthPointCount != 0) {
                    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
                    Date date1 = new Date(System.currentTimeMillis());
                    String lastEditTime = formatter.format(date1);
                    allpointsaveMapper.updateAllPoint(checkId, s, part2FourthId, lastEditTime);
                } else {
                    Allpointsave allpointsave = new Allpointsave();
                    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
                    Date date1 = new Date(System.currentTimeMillis());
                    allpointsave.setNewCreateTime(formatter.format(date1));
                    allpointsave.setLastEditTime(formatter.format(date1));
                    allpointsave.setProjectId(projectId);
                    allpointsave.setCheckId(checkId);
                    allpointsave.setNumber(part2FourthId);
                    allpointsave.setPoint(s);
                    allpointsaveMapper.insert(allpointsave);
                }
            }
            String t = df.format(point3);
            int allPointSaveThirdPointCount = allpointsaveMapper.getAllPointCountByCheckId(checkId, thirdId);
            if (allPointSaveThirdPointCount != 0) {
                SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
                Date date1 = new Date(System.currentTimeMillis());
                String lastEditTime = formatter.format(date1);
                allpointsaveMapper.updateAllPoint(checkId, t, thirdId, lastEditTime);
            } else {
                Allpointsave allpointsave = new Allpointsave();
                SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
                Date date1 = new Date(System.currentTimeMillis());
                allpointsave.setNewCreateTime(formatter.format(date1));
                allpointsave.setLastEditTime(formatter.format(date1));
                allpointsave.setProjectId(projectId);
                allpointsave.setCheckId(checkId);
                allpointsave.setNumber(thirdId);
                allpointsave.setPoint(t);
                allpointsaveMapper.insert(allpointsave);
            }
        }

        //质量隐患评估总体情况以及分项情况
        List<String> zlResultBarCategories = new ArrayList<>();
        List<Integer> zlResultBarData0 = new ArrayList<>();
        List<Integer> zlResultBarData1 = new ArrayList<>();
        List<Double> zlResultBarData2 = new ArrayList<>();

        List<Integer> allZLThirdIdList = problemCollectDetailMapper.getAllThirdIdByFirstId(checkId, 628);
        double allZLweight3 = 0;
        double zlPoint = 0;
        for (int v = 0; v < allZLThirdIdList.size(); v++) {
            double Tweight3 = 0;
            int thirdId = allZLThirdIdList.get(v);
            String newWeight3 = editableweightpsMapper.getWeightByNumber(thirdId, taskId);
            if (StringUtils.isBlank(newWeight3)) {
                Tweight3 = pointsCalculate.getPercentInstance(newWeight3);
            } else {
                String trueweight3 = prefixsystemMapper.getWeight3ByThirdId(thirdId);
                Tweight3 = pointsCalculate.getPercentInstance(trueweight3);
            }
            allZLweight3 += Tweight3;
        }
        List<Object> zlList = new ArrayList<>();
        for (int i = 0; i < allZLThirdIdList.size(); i++) {
            List<String> zlInnerResultBarCategories = new ArrayList<>();
            List<Integer> zlInnerResultBarData0 = new ArrayList<>();
            List<Double> zlInnerResultBarData1 = new ArrayList<>();
            List<Double> zlInnerResultBarData2 = new ArrayList<>();

            Map<String, Object> allThirdInfoMap = new HashMap<>();
            allThirdInfoMap.put("pName3", prefixsystemMapper.getName4ByName4Id(allZLThirdIdList.get(i)));
            zlResultBarCategories.add(prefixsystemMapper.getName4ByName4Id(allZLThirdIdList.get(i)));
            String newZLWeight3 = editableweightpsMapper.getWeightByNumber(allZLThirdIdList.get(i), taskId);
            Double zlWeight3 = 0.0;
            if (StringUtils.isNotBlank(newZLWeight3)) {
                zlWeight3 = pointsCalculate.getPercentInstance(newZLWeight3) / allZLweight3;
            } else {
                zlWeight3 = pointsCalculate.getPercentInstance(prefixsystemMapper.getWeight3ByThirdId(allZLThirdIdList.get(i))) / allZLweight3;
            }
            allThirdInfoMap.put("weight3", df.format(zlWeight3));
            int zlProblemNum = problemCollectDetailMapper.getProblemNumByThirdId(checkId, allZLThirdIdList.get(i));
            int riskPointOver3Num = problemCollectDetailMapper.getRiskPointNumOver3ByThirdId(checkId, allZLThirdIdList.get(i), type3List);
            allThirdInfoMap.put("problemNum", zlProblemNum);
            allThirdInfoMap.put("riskOver3Num", riskPointOver3Num);
            zlResultBarData0.add(zlProblemNum);
            zlResultBarData1.add(riskPointOver3Num);
            String point3 = allpointsaveMapper.getPointByCheckIdAndNumber(checkId, allZLThirdIdList.get(i));
            allThirdInfoMap.put("point3", point3);
            zlResultBarData2.add(Double.parseDouble(point3));
            zlPoint += Double.parseDouble(point3) * zlWeight3;
            List<ProblemCollectDetail> zlFourthInfoList = problemCollectDetailMapper.getZJFourthPoint(checkId, allZLThirdIdList.get(i));
            List<Object> zlFourthList = new ArrayList<>();
            for (int j = 0; j <= zlFourthInfoList.size(); j++) {
                Map<String, Object> allFourthInfoMap = new HashMap<>();
                allFourthInfoMap.put("pName4", prefixsystemMapper.getName4ByName4Id(zlFourthInfoList.get(j).getFourthId()));
                zlInnerResultBarCategories.add(prefixsystemMapper.getName4ByName4Id(zlFourthInfoList.get(j).getFourthId()));
                int zlProblemNum4 = problemCollectDetailMapper.getProblemNumByFourthId(checkId, zlFourthInfoList.get(j).getFourthId());
                allFourthInfoMap.put("problemNum", zlProblemNum4);
                zlInnerResultBarData0.add(zlProblemNum4);

                List<ProblemCollectDetail> sixthPoints = problemCollectDetailMapper.getsixthPoints(checkId, zlFourthInfoList.get(j).getFourthId());
                String pointName6Info = JSON.toJSONString(sixthPoints, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray sixthPointsArray = JSONArray.parseArray(pointName6Info);
                double calculatePoint6 = 0;
                double calculatePoint66 = 0;
                double calculateTruePoint = 0;
                for (int y = 0; y < sixthPointsArray.size(); y++) {
                    JSONObject sixPointObject = sixthPointsArray.getJSONObject(y);
                    int deductSixthId = sixPointObject.getIntValue("sixthId");
                    float deductPointsSumFloat = problemCollectDetailMapper.getdeductSum(checkId, deductSixthId);
                    double deductPointsSum = Double.valueOf(String.valueOf(deductPointsSumFloat));
                    double truePoint = Double.parseDouble(sixPointObject.getString("point6"));
                    if (truePoint <= deductPointsSum) {
                        calculatePoint66 = 0;
                    } else {
                        calculatePoint66 = truePoint - deductPointsSum;
                    }
                    calculateTruePoint += truePoint;
                    calculatePoint6 += calculatePoint66;
                }
                double noProblemPoint = 0;
                List<Object> noProblemSixthIdList = uncheckeditemsMapper.getNoProblemSixthId(checkId, zlFourthInfoList.get(j).getFourthId());
                String noProblemSixthIdInfo = JSON.toJSONString(noProblemSixthIdList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray noProblemSixthArray = JSONArray.parseArray(noProblemSixthIdInfo);
                for (int m = 0; m < noProblemSixthArray.size(); m++) {
                    int noProblemSixthId = noProblemSixthArray.getIntValue(m);
                    double noProblem = Double.parseDouble(prefixsystemMapper.getPoint4ByPoint4Id(noProblemSixthId));
                    noProblemPoint += noProblem;
                }
                double checkItemPoint = (calculatePoint6 + noProblemPoint) / (calculateTruePoint + noProblemPoint) * 100;
                List<ProblemCollectDetail> checkItemCalcuList = problemCollectDetailMapper.getAllFourthInfo(checkId, zlFourthInfoList.get(j).getFourthId());
                String maxFourthRiskPoint = pointsCalculate.getMaxRiskPoint(checkItemCalcuList);
                int maxFourthRiskPointNum = problemCollectDetailMapper.getRiskPointCount(checkId, zlFourthInfoList.get(j).getFourthId(), maxFourthRiskPoint);
                double limitFourhPoint = Double.parseDouble((pointlimitMapper.getLimitPointByInfo(String.valueOf(maxFourthRiskPointNum), maxFourthRiskPoint)) == null ? "100" : pointlimitMapper.getLimitPointByInfo(String.valueOf(maxFourthRiskPointNum), maxFourthRiskPoint));
                if (checkItemPoint > limitFourhPoint) {
                    checkItemPoint = limitFourhPoint;
                }
                String fourthPoint = df.format(checkItemPoint);
                zlInnerResultBarData2.add(Double.parseDouble(fourthPoint));
                double deductPoint = calculateTruePoint - calculatePoint6;
                String ideaPoint = df.format(calculateTruePoint + noProblemPoint);
                allFourthInfoMap.put("ideaPoint", ideaPoint);
                allFourthInfoMap.put("deductPoint", deductPoint);
                zlInnerResultBarData1.add(deductPoint);
                zlFourthList.add(allFourthInfoMap);
            }
            allThirdInfoMap.put("zlFourthList", zlFourthList);
            //质量分部工程分项评估柱状图
            try {
                HashMap<String, String> zlInnerResultBar = new HashMap<>();
                Map<String, Object> zlInnerResultBarInfos = new HashMap<>();
                Map<String, Object> zlInnerResultBarInfo0 = new HashMap<>();
                zlInnerResultBarInfo0.put("name", "不符合项数量");
                zlInnerResultBarInfo0.put("color", "rgb(75,67,232)");
                zlInnerResultBarInfo0.put("data", zlInnerResultBarData0);
                Map<String, Object> zlInnerResultBarInfo1 = new HashMap<>();
                zlInnerResultBarInfo1.put("name", "分项扣分");
                zlInnerResultBarInfo1.put("color", "red");
                zlInnerResultBarInfo1.put("data", zlInnerResultBarData1);
                Map<String, Object> zlInnerResultBarInfo2 = new HashMap<>();
                zlInnerResultBarInfo2.put("name", "分项最终得分");
                zlInnerResultBarInfo2.put("color", "#00CD00");
                zlInnerResultBarInfo2.put("data", zlInnerResultBarData2);
                Object[] zlInnerResultBarInfo = new Object[]{zlInnerResultBarInfo0, zlInnerResultBarInfo1, zlInnerResultBarInfo2};
                zlInnerResultBarInfos.put("series", zlInnerResultBarInfo);
                zlInnerResultBarInfos.put("subtitle", prefixsystemMapper.getName4ByName4Id(allZLThirdIdList.get(i)) + ":" + df.format(zlPoint));
                zlInnerResultBarInfos.put("title", "分部工程评估结果");
                zlInnerResultBarInfos.put("categories", zlInnerResultBarCategories);
                zlInnerResultBar.put("dataSet", JSON.toJSONString(zlInnerResultBarInfos));
                zlInnerResultBar.put("width", "718");
                zlInnerResultBar.put("height", "468");
                zlInnerResultBar.put("index", "7");
                String zlInnerResultBarPic = HttpUtil.post("http://localhost:3000/highcharts", zlInnerResultBar, "utf-8");
                allThirdInfoMap.put("zlInnerResultBarPic", zlInnerResultBarPic.substring(22));
            } catch (Exception e) {
                e.printStackTrace();
            }
            zlList.add(allThirdInfoMap);
        }
        dataMap.put("zlList", zlList);
        dataMap.put("zlPoint", df.format(zlPoint));
        //质量分项评估柱状图
        try {
            HashMap<String, String> zlResultBar = new HashMap<>();
            Map<String, Object> zlResultBarInfos = new HashMap<>();
            Map<String, Object> zlResultBarInfo0 = new HashMap<>();
            zlResultBarInfo0.put("name", "不符合项数量");
            zlResultBarInfo0.put("color", "rgb(75,67,232)");
            zlResultBarInfo0.put("data", zlResultBarData0);
            Map<String, Object> zlResultBarInfo1 = new HashMap<>();
            zlResultBarInfo1.put("name", "3级以上问题数量");
            zlResultBarInfo1.put("color", "red");
            zlResultBarInfo1.put("data", zlResultBarData1);
            Map<String, Object> zlResultBarInfo2 = new HashMap<>();
            zlResultBarInfo2.put("name", "分项得分");
            zlResultBarInfo2.put("color", "#00CD00");
            zlResultBarInfo2.put("data", zlResultBarData2);
            Object[] zlResultBarInfo = new Object[]{zlResultBarInfo0, zlResultBarInfo1, zlResultBarInfo2};
            zlResultBarInfos.put("series", zlResultBarInfo);
            zlResultBarInfos.put("title", "质量隐患评估结果");
            zlResultBarInfos.put("subtitle", "质量隐患得分:" + df.format(zlPoint));
            zlResultBarInfos.put("categories", zlResultBarCategories);
            zlResultBar.put("dataSet", JSON.toJSONString(zlResultBarInfos));
            zlResultBar.put("width", "718");
            zlResultBar.put("height", "468");
            zlResultBar.put("index", "7");
            String zlResultBarPic = HttpUtil.post("http://localhost:3000/highcharts", zlResultBar, "utf-8");
            dataMap.put("zlResultBarPic", zlResultBarPic.substring(22));
        } catch (Exception e) {
            e.printStackTrace();
        }

        List<String> zlAllResultBarCategories = new ArrayList<>();
        List<Double> zlAllResultBarData0 = new ArrayList<>();
        List<Double> zlAllResultBarData1 = new ArrayList<>();
        List<Double> zlAllResultBarData2 = new ArrayList<>();
        List<String> zlAllResultBarData3 = new ArrayList<>();

        List<String> glResultBarCategories = new ArrayList<>();
        List<Integer> glResultBarData0 = new ArrayList<>();
        //List<Integer> glResultBarData1=new ArrayList<>();
        List<Double> glResultBarData2 = new ArrayList<>();

        List<Integer> allGLFourthIdList = problemCollectDetailMapper.getAllFourthIdByNum(checkId, 736);
        List<Object> glList = new ArrayList<>();
        for (int i = 0; i < allGLFourthIdList.size(); i++) {
            Map<String, Object> glInfoMap = new HashMap<>();
            glInfoMap.put("no", i + 1);
            glInfoMap.put("pName4", prefixsystemMapper.getName4ByName4Id(allGLFourthIdList.get(i)));
            glResultBarCategories.add(prefixsystemMapper.getName4ByName4Id(allGLFourthIdList.get(i)));
            zlAllResultBarCategories.add(prefixsystemMapper.getName4ByName4Id(allGLFourthIdList.get(i)));
            zlAllResultBarData0.add(Double.parseDouble(scslPoint));
            zlAllResultBarData1.add(zlPoint);
            int glProblemNum4 = problemCollectDetailMapper.getProblemNumByFourthId(checkId, allGLFourthIdList.get(i));
            glResultBarData0.add(glProblemNum4);
            glInfoMap.put("problemNum", glProblemNum4);
            String point4 = allpointsaveMapper.getPointByCheckIdAndNumber(checkId, allGLFourthIdList.get(i));
            glInfoMap.put("point4", point4);
            zlAllResultBarData2.add(Double.parseDouble(point4));
            glResultBarData2.add(Double.parseDouble(point4));
            String allOverPoint = df.format(Double.parseDouble(scslPoint) * 0.3 + zlPoint * 0.4 + Double.parseDouble(point4) * 0.3);
            glInfoMap.put("allOverPoint", allOverPoint);
            zlAllResultBarData3.add(allOverPoint);
            glList.add(glInfoMap);
        }
        dataMap.put("glList", glList);
        //管理行为分项评估柱状图
        try {
            HashMap<String, String> glResultBar = new HashMap<>();
            Map<String, Object> glResultBarInfos = new HashMap<>();
            Map<String, Object> glResultBarInfo0 = new HashMap<>();
            glResultBarInfo0.put("name", "不符合项数量");
            glResultBarInfo0.put("color", "rgb(75,67,232)");
            glResultBarInfo0.put("data", glResultBarData0);
            /*Map<String,Object> glResultBarInfo1=new HashMap<>();
            glResultBarInfo1.put("name","3级以上风险数量");
            glResultBarInfo1.put("color","red");
            glResultBarInfo1.put("data",glResultBarData1);*/
            Map<String, Object> glResultBarInfo2 = new HashMap<>();
            glResultBarInfo2.put("name", "分项得分");
            glResultBarInfo2.put("color", "#00CD00");
            glResultBarInfo2.put("data", glResultBarData2);
            Object[] glResultBarInfo = new Object[]{glResultBarInfo0, glResultBarInfo2};
            glResultBarInfos.put("series", glResultBarInfo);
            glResultBarInfos.put("title", "管理行为评估结果");
            glResultBarInfos.put("categories", glResultBarCategories);
            glResultBar.put("dataSet", JSON.toJSONString(glResultBarInfos));
            glResultBar.put("width", "718");
            glResultBar.put("height", "468");
            glResultBar.put("index", "4");
            String glResultBarPic = HttpUtil.post("http://localhost:3000/highcharts", glResultBar, "utf-8");
            dataMap.put("glResultBarPic", glResultBarPic.substring(22));
        } catch (Exception e) {
            e.printStackTrace();
        }

        //综合评估柱状图
        try {
            HashMap<String, String> zlAllResultBar = new HashMap<>();
            Map<String, Object> zlAllResultBarInfos = new HashMap<>();
            Map<String, Object> zlAllResultBarInfo0 = new HashMap<>();
            zlAllResultBarInfo0.put("name", "实测实量(30%)");
            zlAllResultBarInfo0.put("color", "red");
            zlAllResultBarInfo0.put("data", zlAllResultBarData0);
            Map<String, Object> zlAllResultBarInfo1 = new HashMap<>();
            zlAllResultBarInfo1.put("name", "质量风险(40%)");
            zlAllResultBarInfo1.put("color", "rgb(75,67,232)");
            zlAllResultBarInfo1.put("data", zlAllResultBarData1);
            Map<String, Object> zlAllResultBarInfo2 = new HashMap<>();
            zlAllResultBarInfo2.put("name", "管理行为(30%)");
            zlAllResultBarInfo2.put("color", "rgb(232,137,31)");
            zlAllResultBarInfo2.put("data", zlAllResultBarData2);
            Map<String, Object> zlAllResultBarInfo3 = new HashMap<>();
            zlAllResultBarInfo3.put("name", "综合评分");
            zlAllResultBarInfo3.put("color", "rgb(190,190,190)");
            zlAllResultBarInfo3.put("data", zlAllResultBarData3);
            Object[] zlAllResultBarInfo = new Object[]{zlAllResultBarInfo0, zlAllResultBarInfo1, zlAllResultBarInfo2};
            zlAllResultBarInfos.put("series", zlAllResultBarInfo);
            zlAllResultBarInfos.put("title", "质量风险评估结果");
            zlAllResultBarInfos.put("categories", zlAllResultBarCategories);
            zlAllResultBar.put("dataSet", JSON.toJSONString(zlAllResultBarInfos));
            zlAllResultBar.put("width", "718");
            zlAllResultBar.put("height", "468");
            zlAllResultBar.put("index", "4");
            String zlAllResultBarPic = HttpUtil.post("http://localhost:3000/highcharts", zlAllResultBar, "utf-8");
            dataMap.put("zlAllResultBarPic", zlAllResultBarPic.substring(22));
        } catch (Exception e) {
            e.printStackTrace();
        }

        //质量问题汇总表
        List<ProblemCollectDetail> zlProblemInfo = problemCollectDetailMapper.getAllInfoByFirstId(checkId, 628);
        List<Object> zlProblemList = new ArrayList<>();
        for (int i = 0; i < zlProblemInfo.size(); i++) {
            Map<String, Object> zlProblemMap = new HashMap<>();
            zlProblemMap.put("no", i + 1);
            zlProblemMap.put("pName3", zlProblemInfo.get(i).getpName3());
            zlProblemMap.put("pName4", zlProblemInfo.get(i).getpName4());
            if (zlProblemInfo.get(i).getIsRemark().equals("N")) {
                zlProblemMap.put("problemDescription", zlProblemInfo.get(i).getProblemDescription());
            } else if (zlProblemInfo.get(i).getIsRemark().equals("Y")) {
                zlProblemMap.put("problemDescription", zlProblemInfo.get(i).getRemark());
            }
            zlProblemMap.put("riskPoint", zlProblemInfo.get(i).getRiskPoint());
            zlProblemList.add(zlProblemMap);
        }
        dataMap.put("zlProblemList", zlProblemList);

        List<Object> glProblemList = new ArrayList<>();
        for (int i = 0; i < allGLFourthIdList.size(); i++) {
            Map<String, Object> glProblemMap = new HashMap<>();
            glProblemMap.put("pName4", prefixsystemMapper.getName4ByName4Id(allGLFourthIdList.get(i)));
            List<ProblemCollectDetail> allGLFourthProblemInfo = problemCollectDetailMapper.getAllFourthInfo(checkId, allGLFourthIdList.get(i));
            List<Object> glProblemInnerList = new ArrayList<>();
            for (int j = 0; j < allGLFourthProblemInfo.size(); j++) {
                Map<String, Object> glProblemInnerMap = new HashMap<>();
                glProblemInnerMap.put("no", j + 1);
                glProblemInnerMap.put("pName6", allGLFourthProblemInfo.get(j).getpName6());
                if (allGLFourthProblemInfo.get(j).getIsRemark().equals("N")) {
                    glProblemInnerMap.put("problemDescription", allGLFourthProblemInfo.get(j).getProblemDescription());
                } else if (allGLFourthProblemInfo.get(j).getIsRemark().equals("Y")) {
                    glProblemInnerMap.put("problemDescription", allGLFourthProblemInfo.get(j).getRemark());
                }
                glProblemInnerMap.put("riskPoint", allGLFourthProblemInfo.get(j).getRiskPoint());
                glProblemInnerList.add(glProblemInnerMap);
            }
            glProblemList.add(glProblemMap);
        }
        dataMap.put("glProblemList", glProblemList);

        //第三部分，质量问题各分项检查情况
        List<Object> pName1Info = problemCollectDetailMapper.getAllName1Id(checkId);
        String name1 = JSON.toJSONString(pName1Info, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        JSONArray name1Array = JSONArray.parseArray(name1);
        String section2pName1 = "";
        List<Object> section2List = new ArrayList<Object>();
        for (int b = 0; b < name1Array.size(); b++) {
            Map<String, Object> section2Name1Map = new HashMap<String, Object>();
            List<Object> section2name1List = new ArrayList<Object>();
            String section2name1 = prefixsystemMapper.getName4ByName4Id(name1Array.getIntValue(b));
            if (section2name1.equals("安全检查")) {
                section2pName1 = "安全问题";
            } else if (section2name1.equals("质量检查")) {
                section2pName1 = "质量问题";
            } else if (section2name1.equals("管理行为")) {
                section2pName1 = "管理体系及管理动作";
            }
            section2Name1Map.put("section2pName1", section2pName1);
            List<Object> section2Name4Info = problemCollectDetailMapper.getAllName4ByName1(checkId, section2name1);
            String section2Name44 = JSON.toJSONString(section2Name4Info, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
            JSONArray section2Name4Array = JSONArray.parseArray(section2Name44);
            for (int w = 0; w < section2Name4Array.size(); w++) {
                Map<String, Object> section2Name4Map = new HashMap<String, Object>();
                List<Object> section2Name4List = new ArrayList<Object>();
                int section2Name4Id = section2Name4Array.getIntValue(w);
                String section2Name4 = prefixsystemMapper.getName4ByName4Id(section2Name4Id);
                List<ProblemCollectDetail> section2Name6Info = problemCollectDetailMapper.getAllName6InfoByName4(checkId, section2Name4Id, section2name1);
                String section2Name66 = JSON.toJSONString(section2Name6Info, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray section2Name6Array = JSONArray.parseArray(section2Name66);
                for (int c = 0; c < section2Name6Array.size(); c++) {
                    Map<String, Object> section2Name6Map = new HashMap<String, Object>();
                    List<Object> picList = new ArrayList<Object>();
                    JSONObject section2Name6Object = section2Name6Array.getJSONObject(c);
                    section2Name6Map.put("section2pName6No", c + 1);
                    section2Name6Map.put("section2pName6", section2Name6Object.getString("pName6"));
                    section2Name6Map.put("section2pName5", section2Name6Object.getString("pName5"));
                    section2Name6Map.put("section2RiskLevel", section2Name6Object.getString("riskPoint"));
                    section2Name6Map.put("section2CheckPart", section2Name6Object.getString("checkPart"));
                    section2Name6Map.put("section2ProblemNum", section2Name6Object.getString("problemQua"));
                    if (section2Name6Object.getString("isRemark").equals("N")) {
                        section2Name6Map.put("section2problemDescription", section2Name6Object.getString("problemDescription"));
                    } else if (section2Name6Object.getString("isRemark").equals("Y")) {
                        section2Name6Map.put("section2problemDescription", section2Name6Object.getString("remark"));
                    }
                    section2Name6Map.put("section2normsProvison", section2Name6Object.getString("normsProvison"));
                    section2Name6Map.put("section2suggestion", section2Name6Object.getString("suggestion"));
                    String section2picPath = section2Name6Object.getString("picPath");
                    String picName = section2Name6Object.getString("picName");
                    JSONArray ja = JSONArray.parseArray(picName);
                    if (ja.size() == 0) {
                        //String s = MDoc.getImageStr("C:\\Users\\96500\\Desktop\\20190329183836002.png");
                        String s = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                        picList.add(s);
                    } else {
                        for (int o = 0; o < ja.size(); o++) {
                            String s="";
                            if( "prod".equals(profiles.getActives()) ){
                                s = MDoc.getImageStr(section2picPath + ja.getString(o));
                            }

                            //String s = MDoc.getImageStr("C:\\Users\\96500\\Desktop\\20190329183836002.png");
                            picList.add(s);
                        }
                    }
                    section2Name6Map.put("picList", picList);
                    section2Name4List.add(section2Name6Map);

                }
                section2Name4Map.put("section2pName4", section2Name4);
                section2Name4Map.put("section2Name4List", section2Name4List);
                section2name1List.add(section2Name4Map);
            }
            section2Name1Map.put("section2Name1List", section2name1List);
            section2List.add(section2Name1Map);
        }
        dataMap.put("section2List", section2List);

        //改进建议
        List<Summary> glSummaryInfo = summaryMapper.getSummaryInfo(checkId, 628);
        List<Object> glSummaryList = new ArrayList<>();
        for (int i = 0; i < glSummaryInfo.size(); i++) {
            Map<String, Object> glSummaryMap = new HashMap<>();
            glSummaryMap.put("no", i + 1);
            glSummaryMap.put("pName4", prefixsystemMapper.getName4ByName4Id(glSummaryInfo.get(i).getFourthId()));
            glSummaryMap.put("summary", glSummaryInfo.get(i).getSummary() == null ? "" : glSummaryInfo.get(i).getSummary());
            glSummaryList.add(glSummaryMap);
        }
        dataMap.put("glSummaryList", glSummaryList);

        List<Object> zlSummaryList = new ArrayList<>();
        for (int i = 0; i < allZLThirdIdList.size(); i++) {
            Map<String, Object> zlSummaryMap = new HashMap<>();
            zlSummaryMap.put("no", i + 1);
            zlSummaryMap.put("pName3", prefixsystemMapper.getName4ByName4Id(allZLThirdIdList.get(i)));
            List<Summary> allSummaryByThirdId = summaryMapper.getAllSummaryByThirdId(checkId, allZLThirdIdList.get(i));
            if (allSummaryByThirdId.size() == 0) {
                zlSummaryMap.put("summary", "");
            } else {
                String summary = "";
                for (int j = 0; j < allSummaryByThirdId.size(); j++) {
                    summary += (j + 1) + "、" + allSummaryByThirdId.get(j).getSummary() + ";";
                }
                zlSummaryMap.put("summary", summary);
            }
            zlSummaryList.add(zlSummaryMap);
        }
        dataMap.put("zlSummaryList", zlSummaryList);
        MDoc mdoc = new MDoc();
        String path = FileUtil.getServerFolderPath();
        File f1 = new File(path, "doc");
        if (!f1.exists()) {
            f1.mkdirs();
        }
        mdoc.createDoc(dataMap, path + "\\doc\\" + projectObject.getString("projectName").replace('#', '号') + "质量可视化报告" + fileName + ".doc", "ftl\\zlVisible.ftl");
        MDoc.docToDocx("D:\\whutServer\\apache-tomcat-8.5.41\\webapps\\ROOT\\doc\\" + projectObject.getString("projectName").replace('#', '号') + "质量可视化报告" + fileName + ".doc", "D:\\whutServer\\apache-tomcat-8.5.41\\webapps\\ROOT\\doc\\" + projectObject.getString("projectName").replace('#', '号') + "质量可视化报告" + fileName + ".doc");
        String result = urlProperties.getAddress() + "/doc/" + projectObject.getString("projectName").replace('#', '号') + "质量可视化报告" + fileName + ".doc";
        return result;
    }

    @Override
    public String constructionMulCheckReport(int checkId, int projectId,boolean isNew) throws UnsupportedEncodingException {
        return isNew ?NewConstructionMulCheckReport(checkId,projectId,isNew) :oldConstructionMulCheckReport(checkId,projectId,isNew);
    }

    public String oldConstructionMulCheckReport(int checkId, int projectId,boolean isNew) throws UnsupportedEncodingException {
        StandardChartTheme standardChartTheme = new StandardChartTheme("CN");
        //设置标题字体
        standardChartTheme.setExtraLargeFont(new Font("隶书", Font.BOLD, 20));
        //设置图例的字体
        standardChartTheme.setRegularFont(new Font("宋书", Font.PLAIN, 15));
        //设置轴向的字体
        standardChartTheme.setLargeFont(new Font("宋书", Font.PLAIN, 15));
        //应用主题样式
        DecimalFormat df = new DecimalFormat("0.00");
        int width = 718;
        int height = 468;
        ChartFactory.setChartTheme(standardChartTheme);
        Map<String, Object> dataMap = new HashMap<String, Object>();
        Date date = new Date();
        DateFormat d1 = new SimpleDateFormat("yyyyMMddhhmmss");
        DateFormat d2 = new SimpleDateFormat("yyyy");
        DateFormat d3 = new SimpleDateFormat("MM");
        DateFormat d4 = new SimpleDateFormat("dd");
        String day = d4.format(date);
        String month = d3.format(date);
        String year = d2.format(date);
        String fileName = d1.format(date);
        String zlWeight = prefixsystemMapper.getWeight1ByName1("质量检查");
        String aqWeight = prefixsystemMapper.getWeight1ByName1("安全检查");
        String glWeight = prefixsystemMapper.getWeight1ByName1("管理行为");
        dataMap.put("zlWeight", zlWeight);
        dataMap.put("aqWeight", aqWeight);
        dataMap.put("glWeight", glWeight);
        dataMap.put("day", day);
        dataMap.put("month", month);
        dataMap.put("year", year);
        dataMap.put("zlPoint", "\\");
        dataMap.put("glPoint", "\\");
        dataMap.put("aqPoint", "\\");
        dataMap.put("zlLever", "\\");
        dataMap.put("aqLever", "\\");
        dataMap.put("glLever", "\\");
        //工程概况部分，来自ctp的工程信息
        List<ContractTaskProject> projectList = contracttaskprojectMapper.selectAllByCheckId(projectId);
        String project = JSON.toJSONString(projectList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        System.out.println(project);
        JSONArray projectArray = JSONArray.parseArray(project);
        JSONObject projectObject = projectArray.getJSONObject(0);
        dataMap.put("projectName", projectObject.getString("projectName"));
        dataMap.put("projectAddress", projectObject.getString("area"));
        dataMap.put("jsUnit", projectObject.getString("jsUnit"));
        dataMap.put("jlUnit", projectObject.getString("jlUnit"));
        dataMap.put("sgUnit", projectObject.getString("sgUnit"));
        dataMap.put("projectType", projectObject.getString("projectType"));
        dataMap.put("projectPrice", projectObject.getString("projectPrice"));
        dataMap.put("dangerItem", projectObject.getString("dangerItem"));
        dataMap.put("remark", projectObject.getString("remark"));
        dataMap.put("projectDescription", projectObject.getString("projectDescription"));
        String js = projectObject.getString("jsUniter");
        String jl = projectObject.getString("jlUniter");
        String sg = projectObject.getString("manager");
        dataMap.put("jsUniter", js);
        dataMap.put("jlUniter", jl);
        dataMap.put("sgUniter", sg);
        //工程概况部分，来自设备信息表的设备信息部分
        List<Equipinfo> equipinfoList = equipinfoMapper.getAllByProjectId(projectId);
        String equip = JSON.toJSONString(equipinfoList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        JSONArray equipArray = JSONArray.parseArray(equip);
        List<Object> equipList = new ArrayList<Object>();
        if (equipArray.size() == 0) {
            Map<String, Object> eqMap = new HashMap<String, Object>();
            eqMap.put("equipType", "\\");
            eqMap.put("equipQua", "\\");
            eqMap.put("equipNum", "\\");
            eqMap.put("equipLeaseUnit", "\\");
            eqMap.put("equipUseUnit", "\\");
            eqMap.put("demolitionUnit", "\\");
            eqMap.put("testUnit", "\\");
            equipList.add(eqMap);
        } else {
            for (int i = 0; i < equipArray.size(); i++) {
                Map<String, Object> eqMap = new HashMap<String, Object>();
                JSONObject equipObject = equipArray.getJSONObject(i);
                eqMap.put("equipType", equipObject.getString("equipType"));
                eqMap.put("equipQua", equipObject.getString("equipQua"));
                eqMap.put("equipNum", equipObject.getString("equipNum"));
                eqMap.put("equipLeaseUnit", equipObject.getString("equipLeaseUnit"));
                eqMap.put("equipUseUnit", equipObject.getString("equipUseUnit"));
                eqMap.put("demolitionUnit", equipObject.getString("demolitionUnit"));
                eqMap.put("testUnit", equipObject.getString("testUnit"));
                equipList.add(eqMap);
            }
        }
        dataMap.put("equipList", equipList);
        //第一部分，综合评估结果，从合同任务检查表中获取相关信息,签名部分
        List<ContractCheckTask> checkInfo = contractchecktaskMapper.getCheckInfoByCheckId(checkId);
        String check = JSON.toJSONString(checkInfo, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        JSONArray checkArray = JSONArray.parseArray(check);
        JSONObject checkObject = checkArray.getJSONObject(0);

//        dataMap.put("jsSign", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png"));
//        dataMap.put("jlSign", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png"));
//        dataMap.put("sgSign", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png"));
        String signPicPath = checkObject.getString("signPath");
        String jsSign = checkObject.getString("jsSign");
        String jlSign = checkObject.getString("jlSign");
        String sgSign = checkObject.getString("sgSign");
        if (signPicPath == null || signPicPath.equals("")) {
            dataMap.put("jsSign", MDoc.getImageStr("D:\\whutServer\\generatedCharts\\blank.png"));
            dataMap.put("jlSign", MDoc.getImageStr("D:\\whutServer\\generatedCharts\\blank.png"));
            dataMap.put("sgSign", MDoc.getImageStr("D:\\whutServer\\generatedCharts\\blank.png"));
        } else {
            dataMap.put("jsSign", MDoc.getImageStr(signPicPath + jsSign));
            dataMap.put("jlSign", MDoc.getImageStr(signPicPath + jlSign));
            dataMap.put("sgSign", MDoc.getImageStr(signPicPath + sgSign));
        }
        //第一部分，（二）分项评估结果
        Integer taskId = contractchecktaskMapper.getTaskIdByCheckId(checkId);
        List<Object> pName1Info = problemCollectDetailMapper.getAllName1Id(checkId);
        String name1 = JSON.toJSONString(pName1Info, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        JSONArray name1Array = JSONArray.parseArray(name1);   //firstId
        float allExtraPointFloat = problemCollectDetailMapper.getAllExtraPoint(checkId);
        double allExtraPoint = Double.valueOf(String.valueOf(allExtraPointFloat));
        double overAllPoint = 0;
        List<Object> part2List = new ArrayList<Object>();
        String Name1 = "";
        double allweight1 = 0;
        //质量和安全对调
        int securitySort = 0;
        int quilitySort = 0;
        for (int i = 0; i < name1Array.size(); i++) {
            double Tweight1 = 0;
            String weight1 = prefixsystemMapper.getWeight1ByName1(prefixsystemMapper.getName4ByName4Id(name1Array.getIntValue(i)));
            Tweight1 = pointsCalculate.getPercentInstance(weight1);
            allweight1 += Tweight1;
            if (name1Array.getIntValue(i) == 1) {
                securitySort = i;
            } else if (name1Array.getIntValue(i) == 628) {
                quilitySort = i;
            }
        }
        if (securitySort != 0 || quilitySort != 0) {
            Collections.swap(name1Array, securitySort, quilitySort);
        }
        for (int k = 0; k < name1Array.size(); k++) {
            Map<String, Object> part2Map = new HashMap<String, Object>();
            List<Object> part2InnerList = new ArrayList<Object>();
            String pName1 = prefixsystemMapper.getName4ByName4Id(name1Array.getIntValue(k)); //通过firstId找到pName1
            double Tweight1 = 0;
            String weight1 = prefixsystemMapper.getWeight1ByName1(pName1);  //获取权重
            Tweight1 = pointsCalculate.getPercentInstance(weight1);
            if (pName1.equals("安全检查")) {
                List<ProblemCollectDetail> list = problemCollectDetailMapper.getAllInfoByName1(checkId, pName1);
                dataMap.put("aqLever", pointsCalculate.getMaxRiskPoint(list));
                Name1 = "安全文明";
            } else if (pName1.equals("质量检查")) {
                List<ProblemCollectDetail> list = problemCollectDetailMapper.getAllInfoByName1(checkId, pName1);
                dataMap.put("zlLever", pointsCalculate.getMaxRiskPoint(list));
                Name1 = "质量风险";
            } else if (pName1.equals("管理行为")) {
                List<ProblemCollectDetail> list = problemCollectDetailMapper.getAllInfoByName1(checkId, pName1);
                dataMap.put("glLever", pointsCalculate.getMaxRiskPoint(list));
                Name1 = "管理行为";
            }
            part2Map.put("name1No", k + 1);
            part2Map.put("name1", Name1);
            List<Object> secondIdList = problemCollectDetailMapper.getSecondId(checkId, pName1);  //获取secondIdList
            String secondIdInfo = JSON.toJSONString(secondIdList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
            JSONArray secondIdInfoArray = JSONArray.parseArray(secondIdInfo);
            double allweight2 = 0;
            for (int p = 0; p < secondIdInfoArray.size(); p++) {
                int allsecondId = secondIdInfoArray.getIntValue(p);
                String weight2 = prefixsystemMapper.getWeight3ByThirdId(allsecondId);
                double weight22 = pointsCalculate.getPercentInstance(weight2);
                allweight2 += weight22;
            }
            double allsecondPoint = 0;
            for (int u = 0; u < secondIdInfoArray.size(); u++) {
                int secondId = secondIdInfoArray.getIntValue(u);
                double weight222 = 0;
                String weight2 = prefixsystemMapper.getWeight3ByThirdId(secondId); //获取第三级权重的weight
                weight222 = pointsCalculate.getPercentInstance(weight2);
                double point = 0;

                List<ProblemCollectDetail> fourthPoints = problemCollectDetailMapper.getFourthPoint(checkId, pName1, secondId);
                String fourthCalculateInfo = JSON.toJSONString(fourthPoints, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray fourthPointsCalculateArray = JSONArray.parseArray(fourthCalculateInfo);
                /*//交换质量与安全
                int securitySort = 0;
                int quilitySort = 0;
                for (int j = 0; j < fourthPointsCalculateArray.size(); j++){
                    String nameNote = fourthPointsCalculateArray.getJSONObject(j).getString("pName4");
                    if (nameNote.equals("安全检查")){
                        securitySort = j;
                    }else if(nameNote.equals("质量检查")){
                        quilitySort = j;
                    }
                }
                if (securitySort != 0 && quilitySort != 0){
                    Collections.swap(fourthPointsCalculateArray, securitySort, quilitySort);
                }*/


                //添加无问题项
                List<ProblemCollectDetail> noProblemItemList = problemCollectDetailMapper.getNoProblemItem(checkId, secondId);
                String noProblemCalculateInfo = JSON.toJSONString(noProblemItemList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray noProblemCalculateArray = JSONArray.parseArray(noProblemCalculateInfo);
                for (int j = 0; j < noProblemCalculateArray.size(); j++) {
                    Map<String, Object> part2InnerMap = new HashMap<String, Object>();
                    JSONObject part2InnerObject = noProblemCalculateArray.getJSONObject(j);
                    part2InnerMap.put("pName4", "无问题项");

                    double allweight4 = this.calculateAllWeight4Func(checkId, part2InnerObject, taskId,isNew);
                    double weight3 = 0;
                    double weight4 = 0;
                    int part2FourthId = part2InnerObject.getIntValue("fourthId");
                    int part2ThirdId = part2InnerObject.getIntValue("thirdId");
                    //更改权重来源
                    String newWeight4 = editableweightpsMapper.getWeightByNumber(part2FourthId, taskId);
                    if (StringUtils.isNotBlank(newWeight4)) {
                        weight4 = pointsCalculate.getPercentInstance(newWeight4);
                    } else {
                        weight4 = pointsCalculate.getPercentInstance(part2InnerObject.getString("weight4"));
                    }

                    String newWeight3 = editableweightpsMapper.getWeightByNumber(part2ThirdId, taskId);
                    if (StringUtils.isNotBlank(newWeight3)) {
                        weight3 = pointsCalculate.getPercentInstance(newWeight3);
                    } else {
                        weight3 = pointsCalculate.getPercentInstance(part2InnerObject.getString("weight3"));
                    }

                    String weight4Result = pointsCalculate.double2ToPercent(weight3, allweight4 / weight4);
                    // String weight4Result = this.getPart2InnerListweight4(checkId, part2ThirdId, weight3, weight4, allweight4);
                    part2InnerMap.put("weight4", weight4Result);

                    List<ProblemCollectDetail> sixthPoints = problemCollectDetailMapper.getsixthPoints(checkId, part2FourthId);
                    String pointName6Info = JSON.toJSONString(sixthPoints, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                    JSONArray sixthPointsArray = JSONArray.parseArray(pointName6Info);
                    double calculatePoint6 = 0;
                    double calculateTruePoint = 0;
                    List<Double> calculatePointList = this.calculatePoint6Func(sixthPointsArray, checkId,isNew);
                    calculatePoint6 = calculatePointList.get(0);
                    calculateTruePoint = calculatePointList.get(1);
                    double noProblemPoint = this.calculateNoProblemPointFunc(checkId, part2InnerObject);
                    System.out.println("第六级扣过的分数总分:" + calculatePoint6 + "没有问题的总分:" + noProblemPoint + "第六级总分:" + calculateTruePoint);
                    double checkItemPoint = (calculatePoint6 + noProblemPoint) / (calculateTruePoint + noProblemPoint) * 100;
                    String s = this.getCheckItemPointAndUpdateAllPointSave(checkId, part2FourthId, projectId, checkItemPoint, df);
                    point += checkItemPoint * weight3 / (allweight4 / weight4);
                    part2InnerMap.put("checkItemPoint", s);
                    part2InnerList.add(part2InnerMap);
                }
                for (int j = 0; j < fourthPointsCalculateArray.size(); j++) {
                    Map<String, Object> part2InnerMap = new HashMap<String, Object>();
                    JSONObject part2InnerObject = fourthPointsCalculateArray.getJSONObject(j);
                    part2InnerMap.put("pName4", part2InnerObject.getString("pName4"));

                    double allweight4 = this.calculateAllWeight4Func(checkId, part2InnerObject, taskId,isNew);
                    double weight3 = 0;
                    double weight4 = 0;
                    int part2FourthId = part2InnerObject.getIntValue("fourthId");
                    int part2ThirdId = part2InnerObject.getIntValue("thirdId");
                    //更改权重来源
                    String newWeight4 = editableweightpsMapper.getWeightByNumber(part2FourthId, taskId);
                    if (StringUtils.isNotBlank(newWeight4)) {
                        weight4 = pointsCalculate.getPercentInstance(newWeight4);
                    } else {
                        weight4 = pointsCalculate.getPercentInstance(part2InnerObject.getString("weight4"));
                    }

                    String newWeight3 = editableweightpsMapper.getWeightByNumber(part2ThirdId, taskId);
                    if (StringUtils.isNotBlank(newWeight3)) {
                        weight3 = pointsCalculate.getPercentInstance(newWeight3);
                    } else {
                        weight3 = pointsCalculate.getPercentInstance(part2InnerObject.getString("weight3"));
                    }

                    String weight4Result = this.getPart2InnerListweight4(checkId, part2ThirdId, weight3, weight4, allweight4);
                    part2InnerMap.put("weight4", weight4Result);

                    List<ProblemCollectDetail> sixthPoints = problemCollectDetailMapper.getsixthPoints(checkId, part2FourthId);
                    String pointName6Info = JSON.toJSONString(sixthPoints, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                    JSONArray sixthPointsArray = JSONArray.parseArray(pointName6Info);
                    double calculatePoint6 = 0;
                    double calculateTruePoint = 0;
                    List<Double> calculatePointList = this.calculatePoint6Func(sixthPointsArray, checkId,isNew);
                    calculatePoint6 = calculatePointList.get(1);
                    calculateTruePoint = calculatePointList.get(0);
                    double noProblemPoint = this.calculateNoProblemPointFunc(checkId, part2InnerObject);
                    System.out.println("第六级扣过的分数总分:" + calculatePoint6 + "没有问题的总分:" + noProblemPoint + "第六级总分:" + calculateTruePoint);
                    double checkItemPoint = (calculatePoint6 + noProblemPoint) / (calculateTruePoint + noProblemPoint) * 100;
                    String s = this.getCheckItemPointAndUpdateAllPointSave(checkId, part2FourthId, projectId, checkItemPoint, df);

                    part2InnerMap.put("checkItemPoint", s);
                    point += checkItemPoint * weight3 / (allweight4 / weight4);
                    part2InnerList.add(part2InnerMap);
                }

                List<Object> getThirdId = problemCollectDetailMapper.getThirdId(checkId, pName1, secondId);
                String thirdIdInfo = JSON.toJSONString(getThirdId, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray thirdArray = JSONArray.parseArray(thirdIdInfo);

                double allweight3 = 0;
                for (int v = 0; v < thirdArray.size(); v++) {
                    double Tweight3 = 0;
                    int thirdId = thirdArray.getIntValue(v);
                    String newWeight3 = editableweightpsMapper.getWeightByNumber(thirdId, taskId);
                    if (StringUtils.isNotBlank(newWeight3)) {
                        Tweight3 = pointsCalculate.getPercentInstance(newWeight3);
                    } else {
                        String trueweight3 = prefixsystemMapper.getWeight3ByThirdId(thirdId);
                        Tweight3 = pointsCalculate.getPercentInstance(trueweight3);
                    }
                    allweight3 += Tweight3;
                }
                System.out.println(point + "dasdasdadasd" + allweight3 + "dasdsadsadad" + df.format(point / allweight3));
                double thirdPoint = Double.parseDouble(df.format(point / allweight3));
                double percent2 = Double.parseDouble(df.format(weight222 / allweight2));
                double secondPoint = Double.parseDouble(df.format(thirdPoint * percent2));
                allsecondPoint += secondPoint;
            }

            if (pName1.equals("安全检查")) {
                dataMap.put("aqPoint", allsecondPoint);
            } else if (pName1.equals("质量检查")) {
                dataMap.put("zlPoint", allsecondPoint);
            } else if (pName1.equals("管理行为")) {
                dataMap.put("glPoint", allsecondPoint);
            }
            int firstPointCount = allpointsaveMapper.getAllPointCountByCheckId(checkId, name1Array.getInteger(k));
            if (firstPointCount != 0) {
                SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
                Date date1 = new Date(System.currentTimeMillis());
                String lastEditTime = formatter.format(date1);
                allpointsaveMapper.updateAllPoint(checkId, df.format(allsecondPoint), name1Array.getInteger(k), lastEditTime);
            } else {
                Allpointsave allpointsave = new Allpointsave();
                SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
                Date date1 = new Date(System.currentTimeMillis());
                allpointsave.setNewCreateTime(formatter.format(date1));
                allpointsave.setLastEditTime(formatter.format(date1));
                allpointsave.setCheckId(checkId);
                allpointsave.setNumber(name1Array.getInteger(k));
                allpointsave.setPoint(df.format(allsecondPoint));
                allpointsave.setProjectId(projectId);
                allpointsaveMapper.insert(allpointsave);
            }
            double trueWeight1 = Double.parseDouble(df.format(Tweight1 / allweight1));
            overAllPoint += Double.parseDouble(df.format(trueWeight1 * allsecondPoint));
            part2Map.put("point", allsecondPoint);
            part2Map.put("part2InnerList", part2InnerList);
            part2List.add(part2Map);
        }
        overAllPoint = overAllPoint - allExtraPoint;
        dataMap.put("overAllPoint", overAllPoint);
        //将总分存到ALLPOINTSAVE中
        int allPointInDB = allpointsaveMapper.getAllPointCountByCheckId(checkId, -1);
        if (allPointInDB != 0) {
            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
            Date date1 = new Date(System.currentTimeMillis());
            String lastEditTime = formatter.format(date1);
            allpointsaveMapper.updateAllPoint(checkId, df.format(overAllPoint), -1, lastEditTime);
        } else {
            Allpointsave allpointsave = new Allpointsave();
            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
            Date date1 = new Date(System.currentTimeMillis());
            allpointsave.setNewCreateTime(formatter.format(date1));
            allpointsave.setLastEditTime(formatter.format(date1));
            allpointsave.setCheckId(checkId);
            allpointsave.setNumber(-1);
            allpointsave.setProjectId(projectId);
            allpointsave.setPoint(df.format(overAllPoint));
            allpointsaveMapper.insert(allpointsave);
        }
        //将总分存到CCT表中
        ContractCheckTask contractchecktask = new ContractCheckTask();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
        Date date1 = new Date(System.currentTimeMillis());
        contractchecktask.setLastEditTime(formatter.format(date1));
        contractchecktask.setCheckId(checkId);
        contractchecktask.setTotalPoint(String.valueOf(overAllPoint));
        contractchecktaskMapper.updateByPrimaryKeySelective(contractchecktask);

        List<ProblemCollectDetail> overallList = problemCollectDetailMapper.getAllProblemCollectInfoByCheckId(checkId);
        dataMap.put("overAllLever", pointsCalculate.getMaxRiskPoint(overallList));
        ContractTaskProject contractTaskProjectRiskPoint = new ContractTaskProject();
        contractTaskProjectRiskPoint.setProjectId(projectId);
        contractTaskProjectRiskPoint.setLatestRiskLevel(pointsCalculate.getMaxRiskPoint(overallList));
        contractTaskProjectRiskPoint.setLastEditTime(formatter.format(date1));
        contracttaskprojectMapper.updateByPrimaryKeySelective(contractTaskProjectRiskPoint);
        ContractTaskProject newRiskList = contracttaskprojectMapper.selectByPrimaryKey(projectId);
        String finishTime = contractchecktaskMapper.getFinishTimeByCheckId(checkId);
        if (newRiskList.getCheckTime().equals("") || newRiskList.getCheckTime().compareTo(finishTime) <= 0) {
            try {
                ContractTaskProject contracttaskproject = new ContractTaskProject();
                contracttaskproject.setProjectId(projectId);
                contracttaskproject.setLatestCheckTime(finishTime);
                contracttaskproject.setLastEditTime(formatter.format(date1));
                contracttaskprojectMapper.updateByPrimaryKeySelective(contracttaskproject);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        dataMap.put("part2List", part2List);

        //第三部分 问题分布
        List<Object> part3List = new ArrayList<>();
        int allFourthProblem = 0;
        for (int k = 0; k < name1Array.size(); k++) {
            Map<String, Object> part3Map = new HashMap<String, Object>();
            List<Object> part3InnerList = new ArrayList<Object>();
            String pName1 = prefixsystemMapper.getName4ByName4Id(name1Array.getIntValue(k)); //通过firstId找到pName1
            part3Map.put("name1", pName1);
            List<Object> secondIdList = problemCollectDetailMapper.getSecondId(checkId, pName1);  //获取secondIdList
            String secondIdInfo = JSON.toJSONString(secondIdList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
            JSONArray secondIdInfoArray = JSONArray.parseArray(secondIdInfo);
            //计算第四级的问题总数
            DefaultPieDataset datasetProblemPie = new DefaultPieDataset();
            DefaultCategoryDataset datasetProblemBar = new DefaultCategoryDataset();
            allFourthProblem = this.calculateAllFourthProblem(checkId, secondIdInfoArray,isNew);
            part3Map.put("allProblemNum", allFourthProblem);
            List<Double> percentList = new ArrayList<>();
            List<String> name4List = new ArrayList<>();
            for (int n = 0; n < secondIdInfoArray.size(); n++) {
                int secondId = secondIdInfoArray.getIntValue(n);
                List<ProblemCollectDetail> fourthPoints = problemCollectDetailMapper.getFourthPoint(checkId, pName1, secondId);
                String fourthCalculateInfo = JSON.toJSONString(fourthPoints, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray fourthPointsCalculateArray = JSONArray.parseArray(fourthCalculateInfo);
                for (int j = 0; j < fourthPointsCalculateArray.size(); j++) {
                    Map<String, Object> part3InnerMap = new HashMap<String, Object>();
                    JSONObject part3InnerObject = fourthPointsCalculateArray.getJSONObject(j);
                    String name4 = part3InnerObject.getString("pName4");
                    part3InnerMap.put("nom", j + 1);
                    part3InnerMap.put("name4", name4);
                    int fourthProblemCount = problemCollectDetailMapper.countFourthProblem(checkId, secondId, name4);
                    part3InnerMap.put("problemNum", fourthProblemCount);
                    String percent = pointsCalculate.caculateToPercent(fourthProblemCount, allFourthProblem);
                    part3InnerMap.put("percent", percent);
                    part3InnerList.add(part3InnerMap);
                    datasetProblemPie.setValue(name4 + ":" + percent, new Double(fourthProblemCount));
                    datasetProblemBar.setValue(fourthProblemCount, "各检查分项", name4);
                }
            }

            try {
                JFreeChart chart = ChartFactory.createPieChart("现场施工问题分布饼图",
                        datasetProblemPie,
                        true,
                        true,
                        false);
                final PiePlot plot = (PiePlot) chart.getPlot();
                //设置旋转角度
                plot.setStartAngle(270);
                //设置图表透明图0.0~1.0范围。0.0为完全透明，1.0为完全不透明。
                plot.setForegroundAlpha(0.90f);
                plot.setInteriorGap(0.02);
                chart.getLegend().setVisible(false);
//                File pieChart = new File("E:\\tencent_File\\1296928795\\FileRecv\\" + fileName + "pieChart.png");
                File pieChart = new File("D:\\whutServer\\generatedCharts\\" + fileName + "pieChart.png");
                ChartUtils.saveChartAsPNG(pieChart, chart, width, height);
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                JFreeChart barChart = ChartFactory.createBarChart("现场施工问题分布直方图",
                        "",
                        "数量",
                        datasetProblemBar,
                        PlotOrientation.VERTICAL,
                        true, true, false);
                CategoryPlot plot = (CategoryPlot) barChart.getPlot();
                plot.getRenderer().setSeriesPaint(0, new Color(5, 87, 232));
                BarRenderer barRenderer = (BarRenderer) plot.getRenderer();
                barRenderer.setDefaultItemLabelGenerator(new StandardCategoryItemLabelGenerator());
                barRenderer.setDefaultItemLabelsVisible(true);
                barRenderer.setItemLabelAnchorOffset(-20D);
                barRenderer.setMaximumBarWidth(0.2);
                CategoryAxis categoryAxis = plot.getDomainAxis();
                categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
//                File barChartFile = new File("E:\\tencent_File\\1296928795\\FileRecv\\" + fileName + "barChart.png");
                File barChartFile = new File("D:\\whutServer\\generatedCharts\\" + fileName + "barChart.png");
                ChartUtils.saveChartAsPNG(barChartFile, barChart, width, height);
            } catch (Exception e) {
                e.printStackTrace();
            }
//            part3Map.put("pieChart",MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\" + fileName + "pieChart.png"));
//            part3Map.put("histogram", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\" + fileName + "barChart.png"));
            part3Map.put("pieChart", MDoc.getImageStr("D:\\whutServer\\generatedCharts\\" + fileName + "pieChart.png"));
            part3Map.put("histogram", MDoc.getImageStr("D:\\whutServer\\generatedCharts\\" + fileName + "barChart.png"));

            part3Map.put("part3InnerList", part3InnerList);
            part3List.add(part3Map);
        }
        dataMap.put("part3List", part3List);
//        System.out.println("dataMap:"+dataMap);
        //三.检查问题综述
        List<Object> part4List = new ArrayList<Object>();
        for (int i = 0; i < name1Array.size(); i++) {
            List<Object> part4InnerList = new ArrayList<Object>();
            Map<String, Object> part4Map = new HashMap<String, Object>();
            String pName1 = prefixsystemMapper.getName4ByName4Id(name1Array.getIntValue(i));
            System.out.println("pName1" + pName1);
            List<Summary> summaryList = summaryMapper.getSummaryInfo(checkId, name1Array.getIntValue(i));
            String summaryInfo = JSON.toJSONString(summaryList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
            JSONArray summaryInfoArray = JSONArray.parseArray(summaryInfo);
            for (int j = 0; j < summaryInfoArray.size(); j++) {
                Map<String, Object> part4InnerMap = new HashMap<String, Object>();
                JSONObject part4InnerObject = summaryInfoArray.getJSONObject(j);
                String part4pNname4 = prefixsystemMapper.getName4ByName4Id(part4InnerObject.getIntValue("fourthId"));
                part4InnerMap.put("pName4", part4pNname4);
                part4InnerMap.put("summary", part4InnerObject.getString("summary"));
                part4InnerList.add(part4InnerMap);
            }
            if (pName1.equals("安全检查")) {
                part4Map.put("name1", "安全");
            } else if (pName1.equals("质量检查")) {
                part4Map.put("name1", "质量");
            } else if (pName1.equals("管理行为")) {
                part4Map.put("name1", "管理");
            }
            part4Map.put("part4InnerList", part4InnerList);
            part4List.add(part4Map);
        }
        dataMap.put("part4List", part4List);
        //四、（一）风险隐患分布表
        int txNum = problemCollectDetailMapper.getAllRiskPointCountByType(checkId, "提醒");
        int oneNum = problemCollectDetailMapper.getAllRiskPointCountByType(checkId, "1");
        int twoNum = problemCollectDetailMapper.getAllRiskPointCountByType(checkId, "2");
        int threeNum = problemCollectDetailMapper.getAllRiskPointCountByType(checkId, "3");
        int fourNum = problemCollectDetailMapper.getAllRiskPointCountByType(checkId, "4");
        int allProblemNum = txNum + oneNum + twoNum + threeNum + fourNum;
        dataMap.put("txNum", txNum);
        dataMap.put("oneNum", oneNum);
        dataMap.put("twoNum", twoNum);
        dataMap.put("threeNum", threeNum);
        dataMap.put("fourNum", fourNum);
        dataMap.put("allProblemNum", allProblemNum);
        String txPercent = pointsCalculate.caculateToPercent(txNum, allProblemNum);
        String onePercent = pointsCalculate.caculateToPercent(oneNum, allProblemNum);
        String twoPercent = pointsCalculate.caculateToPercent(twoNum, allProblemNum);
        String threePercent = pointsCalculate.caculateToPercent(threeNum, allProblemNum);
        String fourPercent = pointsCalculate.caculateToPercent(fourNum, allProblemNum);

        dataMap.put("txPercent", txPercent);
        dataMap.put("onePercent", onePercent);
        dataMap.put("twoPercent", twoPercent);
        dataMap.put("threePercent", threePercent);
        dataMap.put("fourPercent", fourPercent);
        //四、（二）风险隐患问题汇总表
        List<Object> partProblemList = new ArrayList<Object>();
        for (int i = 0; i < name1Array.size(); i++) {
            List<Object> partProblemName1List = new ArrayList<Object>();
            Map<String, Object> partProblemMap = new HashMap<String, Object>();
            String pName1 = prefixsystemMapper.getName4ByName4Id(name1Array.getIntValue(i));
            List<Object> problemName4List = problemCollectDetailMapper.getAllName4ByName1(checkId, pName1);
            String problemName4Info = JSON.toJSONString(problemName4List, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
            JSONArray problemName4Array = JSONArray.parseArray(problemName4Info);
            for (int k = 0; k < problemName4Array.size(); k++) {
                List<ProblemCollectDetail> partProblemDetailList = problemCollectDetailMapper.getAllFourthInfo(checkId, problemName4Array.getIntValue(k));
                String partProblemDetailInfo = JSON.toJSONString(partProblemDetailList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray partProblemDetailArray = JSONArray.parseArray(partProblemDetailInfo);
                String problemName4 = prefixsystemMapper.getName4ByName4Id(problemName4Array.getIntValue(k));
                for (int j = 0; j < partProblemDetailArray.size(); j++) {
                    Map<String, Object> partProblemName1Map = new HashMap<String, Object>();
                    JSONObject partProblemObject = partProblemDetailArray.getJSONObject(j);
                    String problemDescription = partProblemObject.getString("problemDescription");
                    String riskPoint = partProblemObject.getString("riskPoint");
                    if (partProblemObject.getString("isRemark").equals("N")) {
                        partProblemName1Map.put("problemDescription", problemDescription);
                    } else if (partProblemObject.getString("isRemark").equals("Y")) {
                        partProblemName1Map.put("problemDescription", partProblemObject.getString("remark"));
                    }
                    partProblemName1Map.put("riskPoint", riskPoint);
                    partProblemName1Map.put("name4", problemName4);
                    partProblemName1List.add(partProblemName1Map);
                }
            }
            if (pName1.equals("安全检查")) {
                partProblemMap.put("name1", "安全");
            } else if (pName1.equals("质量检查")) {
                partProblemMap.put("name1", "质量");
            } else if (pName1.equals("管理行为")) {
                partProblemMap.put("name1", "管理行为");
            }
            partProblemMap.put("partProblemName1List", partProblemName1List);
            partProblemList.add(partProblemMap);
        }
        dataMap.put("partProblemList", partProblemList);
        //第二部分，各部分工程检查情况
        String section2pName1 = "";
        List<Object> section2List = new ArrayList<Object>();
        for (int b = 0; b < name1Array.size(); b++) {
            Map<String, Object> section2Name1Map = new HashMap<String, Object>();
            List<Object> section2name1List = new ArrayList<Object>();
            String section2name1 = prefixsystemMapper.getName4ByName4Id(name1Array.getIntValue(b));
            if (section2name1.equals("安全检查")) {
                section2pName1 = "安全问题";
            } else if (section2name1.equals("质量检查")) {
                section2pName1 = "质量问题";
            } else if (section2name1.equals("管理行为")) {
                section2pName1 = "管理体系及管理动作";
            }
            section2Name1Map.put("section2pName1", section2pName1);
            List<Object> section2Name4Info = problemCollectDetailMapper.getAllName4ByName1(checkId, section2name1);
            String section2Name44 = JSON.toJSONString(section2Name4Info, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
            JSONArray section2Name4Array = JSONArray.parseArray(section2Name44);
            for (int w = 0; w < section2Name4Array.size(); w++) {
                Map<String, Object> section2Name4Map = new HashMap<String, Object>();
                List<Object> section2Name4List = new ArrayList<Object>();
                int section2Name4Id = section2Name4Array.getIntValue(w);
                String section2Name4 = prefixsystemMapper.getName4ByName4Id(section2Name4Id);
                List<ProblemCollectDetail> section2Name6Info = problemCollectDetailMapper.getAllName6InfoByName4(checkId, section2Name4Id, section2name1);
                String section2Name66 = JSON.toJSONString(section2Name6Info, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray section2Name6Array = JSONArray.parseArray(section2Name66);
                for (int c = 0; c < section2Name6Array.size(); c++) {
                    Map<String, Object> section2Name6Map = new HashMap<String, Object>();
                    List<Object> picList = new ArrayList<Object>();
                    JSONObject section2Name6Object = section2Name6Array.getJSONObject(c);
                    section2Name6Map.put("section2pName6No", c + 1);
                    section2Name6Map.put("section2pName6", section2Name6Object.getString("pName6"));
                    section2Name6Map.put("section2pName5", section2Name6Object.getString("pName5"));
                    section2Name6Map.put("section2RiskLevel", section2Name6Object.getString("riskPoint"));
                    section2Name6Map.put("section2CheckPart", section2Name6Object.getString("checkPart"));
                    section2Name6Map.put("section2ProblemNum", section2Name6Object.getString("problemQua"));
                    if (section2Name6Object.getString("isRemark").equals("N")) {
                        section2Name6Map.put("section2problemDescription", section2Name6Object.getString("problemDescription"));
                    } else if (section2Name6Object.getString("isRemark").equals("Y")) {
                        section2Name6Map.put("section2problemDescription", section2Name6Object.getString("remark"));
                    }
                    section2Name6Map.put("section2normsProvison", section2Name6Object.getString("normsProvison"));
                    section2Name6Map.put("section2suggestion", section2Name6Object.getString("suggestion"));
                    String section2picPath = section2Name6Object.getString("picPath");
                    String picName = section2Name6Object.getString("picName");
                    JSONArray ja = JSONArray.parseArray(picName);
                    if (ja.size() == 0) {
//                        String s = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                        String s = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                        picList.add(s);
                    } else {
                        for (int o = 0; o < ja.size(); o++) {
                            String imgFilePath = section2picPath + ja.getString(o);
                            if (!MDoc.isFoundImageStr(imgFilePath)) {
                                imgFilePath = "D:\\whutServer\\generatedCharts\\test.png";
                            }
                            String s = MDoc.getImageStr(imgFilePath);
//                            String s = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                            picList.add(s);
                        }
                    }
                    section2Name6Map.put("picList", picList);
                    section2Name4List.add(section2Name6Map);

                }
                section2Name4Map.put("section2pName4", section2Name4);
                section2Name4Map.put("section2Name4List", section2Name4List);
                section2name1List.add(section2Name4Map);
            }
            section2Name1Map.put("section2Name1List", section2name1List);
            section2List.add(section2Name1Map);
        }
        dataMap.put("section2List", section2List);
        MDoc mdoc = new MDoc();
        String path = FileUtil.getServerFolderPath();
        File f1 = new File(path, "doc");
        if (!f1.exists()) {
            f1.mkdirs();
        }
        //System.out.println("dataMap:"+dataMap);
        String result = "";
//        mdoc.createDoc(dataMap, "E:\\tencent_File\\1296928795\\FileRecv\\yirui\\" + projectObject.getString("projectName").replace('#','号')+"建设局综合检查报告"+fileName + ".doc", "ftl\\constructionMulCheckReport.ftl");
//        MDoc.docToDocx("E:\\tencent_File\\1296928795\\FileRecv\\yirui\\" + projectObject.getString("projectName").replace('#','号')+"建设局综合检查报告"+fileName + ".doc", "E:\\tencent_File\\1296928795\\FileRecv\\yirui" + projectObject.getString("projectName").replace('#','号')+"建设局综合检查报告"+fileName + ".doc");
//        result = "E:\\tencent_File\\1296928795\\FileRecv\\yirui\\" + projectObject.getString("projectName").replace('#','号')+"建设局综合检查报告"+fileName + ".doc";
        mdoc.createDoc(dataMap, path + "\\doc\\" + projectObject.getString("projectName").replace('#', '号') + "建设局综合检查报告" + fileName + ".doc", "ftl\\constructionMulCheckReport.ftl");
        //MDoc.docToDocx("D:\\whutServer\\apache-tomcat-8.5.41\\webapps\\ROOT\\doc\\" + projectObject.getString("projectName").replace('#','号')+"建设局综合检查报告"+fileName + ".doc", "D:\\whutServer\\apache-tomcat-8.5.41\\webapps\\ROOT\\doc\\" + projectObject.getString("projectName").replace('#','号')+"建设局综合检查报告"+fileName + ".doc");
        result = urlProperties.getAddress() + "/doc/" + projectObject.getString("projectName").replace('#', '号') + "建设局综合检查报告" + fileName + ".doc";
        return result;
    }

    public String NewConstructionMulCheckReport(int checkId, int projectId,boolean isNew) throws UnsupportedEncodingException {
        StandardChartTheme standardChartTheme = new StandardChartTheme("CN");
        //设置标题字体
        standardChartTheme.setExtraLargeFont(new Font("隶书", Font.BOLD, 20));
        //设置图例的字体
        standardChartTheme.setRegularFont(new Font("宋书", Font.PLAIN, 15));
        //设置轴向的字体
        standardChartTheme.setLargeFont(new Font("宋书", Font.PLAIN, 15));
        //应用主题样式
        DecimalFormat df = new DecimalFormat("0.00");
        int width = 718;
        int height = 468;
        ChartFactory.setChartTheme(standardChartTheme);
        Map<String, Object> dataMap = new HashMap<String, Object>();
        Date date = new Date();
        DateFormat d1 = new SimpleDateFormat("yyyyMMddhhmmss");
        DateFormat d2 = new SimpleDateFormat("yyyy");
        DateFormat d3 = new SimpleDateFormat("MM");
        DateFormat d4 = new SimpleDateFormat("dd");
        String day = d4.format(date);
        String month = d3.format(date);
        String year = d2.format(date);
        String fileName = d1.format(date);


        String zlWeight = newprefixsystemMapper.getWeight1ByName1("新质量检查");
        String aqWeight = newprefixsystemMapper.getWeight1ByName1("新安全检查");
        String glWeight = newprefixsystemMapper.getWeight1ByName1("新管理行为");
        dataMap.put("zlWeight", zlWeight);
        dataMap.put("aqWeight", aqWeight);
        dataMap.put("glWeight", glWeight);
        dataMap.put("day", day);
        dataMap.put("month", month);
        dataMap.put("year", year);
        dataMap.put("zlPoint", "\\");
        dataMap.put("glPoint", "\\");
        dataMap.put("aqPoint", "\\");
        dataMap.put("zlLever", "\\");
        dataMap.put("aqLever", "\\");
        dataMap.put("glLever", "\\");
        //工程概况部分，来自ctp的工程信息
        List<ContractTaskProject> projectList = contracttaskprojectMapper.selectAllByCheckId(projectId);
        String project = JSON.toJSONString(projectList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        System.out.println(project);
        JSONArray projectArray = JSONArray.parseArray(project);
        JSONObject projectObject = projectArray.getJSONObject(0);
        dataMap.put("projectName", projectObject.getString("projectName"));
        dataMap.put("projectAddress", projectObject.getString("area"));
        dataMap.put("jsUnit", projectObject.getString("jsUnit"));
        dataMap.put("jlUnit", projectObject.getString("jlUnit"));
        dataMap.put("sgUnit", projectObject.getString("sgUnit"));
        dataMap.put("projectType", projectObject.getString("projectType"));
        dataMap.put("projectPrice", projectObject.getString("projectPrice"));
        dataMap.put("dangerItem", projectObject.getString("dangerItem"));
        dataMap.put("remark", projectObject.getString("remark"));
        dataMap.put("projectDescription", projectObject.getString("projectDescription"));
        String js = projectObject.getString("jsUniter");
        String jl = projectObject.getString("jlUniter");
        String sg = projectObject.getString("manager");
        dataMap.put("jsUniter", js);
        dataMap.put("jlUniter", jl);
        dataMap.put("sgUniter", sg);
        //工程概况部分，来自设备信息表的设备信息部分
        List<Equipinfo> equipinfoList = equipinfoMapper.getAllByProjectId(projectId);
        String equip = JSON.toJSONString(equipinfoList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        JSONArray equipArray = JSONArray.parseArray(equip);
        List<Object> equipList = new ArrayList<Object>();
        if (equipArray.size() == 0) {
            Map<String, Object> eqMap = new HashMap<String, Object>();
            eqMap.put("equipType", "\\");
            eqMap.put("equipQua", "\\");
            eqMap.put("equipNum", "\\");
            eqMap.put("equipLeaseUnit", "\\");
            eqMap.put("equipUseUnit", "\\");
            eqMap.put("demolitionUnit", "\\");
            eqMap.put("testUnit", "\\");
            equipList.add(eqMap);
        } else {
            for (int i = 0; i < equipArray.size(); i++) {
                Map<String, Object> eqMap = new HashMap<String, Object>();
                JSONObject equipObject = equipArray.getJSONObject(i);
                eqMap.put("equipType", equipObject.getString("equipType"));
                eqMap.put("equipQua", equipObject.getString("equipQua"));
                eqMap.put("equipNum", equipObject.getString("equipNum"));
                eqMap.put("equipLeaseUnit", equipObject.getString("equipLeaseUnit"));
                eqMap.put("equipUseUnit", equipObject.getString("equipUseUnit"));
                eqMap.put("demolitionUnit", equipObject.getString("demolitionUnit"));
                eqMap.put("testUnit", equipObject.getString("testUnit"));
                equipList.add(eqMap);
            }
        }
        dataMap.put("equipList", equipList);
        //第一部分，综合评估结果，从合同任务检查表中获取相关信息,签名部分
        List<ContractCheckTask> checkInfo = contractchecktaskMapper.getCheckInfoByCheckId(checkId);
        String check = JSON.toJSONString(checkInfo, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        JSONArray checkArray = JSONArray.parseArray(check);
        JSONObject checkObject = checkArray.getJSONObject(0);

//        dataMap.put("jsSign", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png"));
//        dataMap.put("jlSign", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png"));
//        dataMap.put("sgSign", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png"));
        String signPicPath = checkObject.getString("signPath");
        String jsSign = checkObject.getString("jsSign");
        String jlSign = checkObject.getString("jlSign");
        String sgSign = checkObject.getString("sgSign");
        if (signPicPath == null || signPicPath.equals("")) {
            dataMap.put("jsSign", MDoc.getImageStr("D:\\whutServer\\generatedCharts\\blank.png"));
            dataMap.put("jlSign", MDoc.getImageStr("D:\\whutServer\\generatedCharts\\blank.png"));
            dataMap.put("sgSign", MDoc.getImageStr("D:\\whutServer\\generatedCharts\\blank.png"));
        } else {
            dataMap.put("jsSign", MDoc.getImageStr(signPicPath + jsSign));
            dataMap.put("jlSign", MDoc.getImageStr(signPicPath + jlSign));
            dataMap.put("sgSign", MDoc.getImageStr(signPicPath + sgSign));
        }
        //第一部分，（二）分项评估结果
        Integer taskId = contractchecktaskMapper.getTaskIdByCheckId(checkId);
        List<Object> pName1Info = newProblemCollectDetailMapper.getAllName1Id(checkId);
        String name1 = JSON.toJSONString(pName1Info, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        JSONArray name1Array = JSONArray.parseArray(name1);   //firstId
        float allExtraPointFloat = newProblemCollectDetailMapper.getAllExtraPoint(checkId);
        double allExtraPoint = Double.valueOf(String.valueOf(allExtraPointFloat));
        double overAllPoint = 0;
        List<Object> part2List = new ArrayList<Object>();
        String Name1 = "";
        double allweight1 = 0;
        //质量和安全对调
        int securitySort = 0;
        int quilitySort = 0;
        for (int i = 0; i < name1Array.size(); i++) {
            double Tweight1 = 0;
            String weight1 = newprefixsystemMapper.getWeight1ByName1(newprefixsystemMapper.getName4ByName4Id(name1Array.getIntValue(i)));
            Tweight1 = pointsCalculate.getPercentInstance(weight1);
            allweight1 += Tweight1;
            if (name1Array.getIntValue(i) == 1) {
                securitySort = i;
            } else if (name1Array.getIntValue(i) == 628) {
                quilitySort = i;
            }
        }
        if (securitySort != 0 || quilitySort != 0) {
            Collections.swap(name1Array, securitySort, quilitySort);
        }
        for (int k = 0; k < name1Array.size(); k++) {
            Map<String, Object> part2Map = new HashMap<String, Object>();
            List<Object> part2InnerList = new ArrayList<Object>();
            String pName1 = newprefixsystemMapper.getName4ByName4Id(name1Array.getIntValue(k)); //通过firstId找到pName1
            double Tweight1 = 0;
            String weight1 = newprefixsystemMapper.getWeight1ByName1(pName1);  //获取权重
            Tweight1 = pointsCalculate.getPercentInstance(weight1);
            if (pName1.equals("新安全检查")) {
                List<ProblemCollectDetail> list = newProblemCollectDetailMapper.getAllInfoByName1(checkId, pName1);
                dataMap.put("aqLever", pointsCalculate.getMaxRiskPoint(list));
                Name1 = "新安全文明";
            } else if (pName1.equals("新质量检查")) {
                List<ProblemCollectDetail> list = newProblemCollectDetailMapper.getAllInfoByName1(checkId, pName1);
                dataMap.put("zlLever", pointsCalculate.getMaxRiskPoint(list));
                Name1 = "新质量风险";
            } else if (pName1.equals("新管理行为")) {
                List<ProblemCollectDetail> list = newProblemCollectDetailMapper.getAllInfoByName1(checkId, pName1);
                dataMap.put("glLever", pointsCalculate.getMaxRiskPoint(list));
                Name1 = "新管理行为";
            }
            part2Map.put("name1No", k + 1);
            part2Map.put("name1", Name1);
            List<Object> secondIdList = newProblemCollectDetailMapper.getSecondId(checkId, pName1);  //获取secondIdList
            String secondIdInfo = JSON.toJSONString(secondIdList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
            JSONArray secondIdInfoArray = JSONArray.parseArray(secondIdInfo);
            double allweight2 = 0;
            for (int p = 0; p < secondIdInfoArray.size(); p++) {
                int allsecondId = secondIdInfoArray.getIntValue(p);
                String weight2 = newprefixsystemMapper.getWeight3ByThirdId(allsecondId);
                double weight22 = pointsCalculate.getPercentInstance(weight2);
                allweight2 += weight22;
            }
            double allsecondPoint = 0;
            for (int u = 0; u < secondIdInfoArray.size(); u++) {
                int secondId = secondIdInfoArray.getIntValue(u);
                double weight222 = 0;
                String weight2 = newprefixsystemMapper.getWeight3ByThirdId(secondId); //获取第三级权重的weight
                weight222 = pointsCalculate.getPercentInstance(weight2);
                double point = 0;

                List<ProblemCollectDetail> fourthPoints = newProblemCollectDetailMapper.getFourthPoint(checkId, pName1, secondId);
                String fourthCalculateInfo = JSON.toJSONString(fourthPoints, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray fourthPointsCalculateArray = JSONArray.parseArray(fourthCalculateInfo);
                /*//交换质量与安全
                int securitySort = 0;
                int quilitySort = 0;
                for (int j = 0; j < fourthPointsCalculateArray.size(); j++){
                    String nameNote = fourthPointsCalculateArray.getJSONObject(j).getString("pName4");
                    if (nameNote.equals("安全检查")){
                        securitySort = j;
                    }else if(nameNote.equals("质量检查")){
                        quilitySort = j;
                    }
                }
                if (securitySort != 0 && quilitySort != 0){
                    Collections.swap(fourthPointsCalculateArray, securitySort, quilitySort);
                }*/


                //添加无问题项
                List<ProblemCollectDetail> noProblemItemList = newProblemCollectDetailMapper.getNoProblemItem(checkId, secondId);
                String noProblemCalculateInfo = JSON.toJSONString(noProblemItemList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray noProblemCalculateArray = JSONArray.parseArray(noProblemCalculateInfo);
                for (int j = 0; j < noProblemCalculateArray.size(); j++) {
                    Map<String, Object> part2InnerMap = new HashMap<String, Object>();
                    JSONObject part2InnerObject = noProblemCalculateArray.getJSONObject(j);
                    part2InnerMap.put("pName4", "无问题项");

                    double allweight4 = this.calculateAllWeight4Func(checkId, part2InnerObject, taskId,isNew);
                    double weight3 = 0;
                    double weight4 = 0;
                    int part2FourthId = part2InnerObject.getIntValue("fourthId");
                    int part2ThirdId = part2InnerObject.getIntValue("thirdId");
                    //更改权重来源
                    String newWeight4 = editableweightpsMapper.getWeightByNumber(part2FourthId, taskId);
                    if (StringUtils.isNotBlank(newWeight4)) {
                        weight4 = pointsCalculate.getPercentInstance(newWeight4);
                    } else {
                        weight4 = pointsCalculate.getPercentInstance(part2InnerObject.getString("weight4"));
                    }

                    String newWeight3 = editableweightpsMapper.getWeightByNumber(part2ThirdId, taskId);
                    if (StringUtils.isNotBlank(newWeight3)) {
                        weight3 = pointsCalculate.getPercentInstance(newWeight3);
                    } else {
                        weight3 = pointsCalculate.getPercentInstance(part2InnerObject.getString("weight3"));
                    }

                    String weight4Result = pointsCalculate.double2ToPercent(weight3, allweight4 / weight4);
                    // String weight4Result = this.getPart2InnerListweight4(checkId, part2ThirdId, weight3, weight4, allweight4);
                    part2InnerMap.put("weight4", weight4Result);

                    List<ProblemCollectDetail> sixthPoints = newProblemCollectDetailMapper.getsixthPoints(checkId, part2FourthId);
                    String pointName6Info = JSON.toJSONString(sixthPoints, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                    JSONArray sixthPointsArray = JSONArray.parseArray(pointName6Info);
                    double calculatePoint6 = 0;
                    double calculateTruePoint = 0;
                    List<Double> calculatePointList = this.calculatePoint6Func(sixthPointsArray, checkId,isNew);
                    calculatePoint6 = calculatePointList.get(0);
                    calculateTruePoint = calculatePointList.get(1);
                    double noProblemPoint = this.calculateNoProblemPointFunc(checkId, part2InnerObject);
                    System.out.println("第六级扣过的分数总分:" + calculatePoint6 + "没有问题的总分:" + noProblemPoint + "第六级总分:" + calculateTruePoint);
                    double checkItemPoint = (calculatePoint6 + noProblemPoint) / (calculateTruePoint + noProblemPoint) * 100;
                    String s = this.getCheckItemPointAndUpdateAllPointSave(checkId, part2FourthId, projectId, checkItemPoint, df);
                    point += checkItemPoint * weight3 / (allweight4 / weight4);
                    part2InnerMap.put("checkItemPoint", s);
                    part2InnerList.add(part2InnerMap);
                }
                for (int j = 0; j < fourthPointsCalculateArray.size(); j++) {
                    Map<String, Object> part2InnerMap = new HashMap<String, Object>();
                    JSONObject part2InnerObject = fourthPointsCalculateArray.getJSONObject(j);
                    part2InnerMap.put("pName4", part2InnerObject.getString("pName4"));

                    double allweight4 = this.calculateAllWeight4Func(checkId, part2InnerObject, taskId,isNew);
                    double weight3 = 0;
                    double weight4 = 0;
                    int part2FourthId = part2InnerObject.getIntValue("fourthId");
                    int part2ThirdId = part2InnerObject.getIntValue("thirdId");
                    //更改权重来源
                    String newWeight4 = editableweightpsMapper.getWeightByNumber(part2FourthId, taskId);
                    if (StringUtils.isNotBlank(newWeight4)) {
                        weight4 = pointsCalculate.getPercentInstance(newWeight4);
                    } else {
                        weight4 = pointsCalculate.getPercentInstance(part2InnerObject.getString("weight4"));
                    }

                    String newWeight3 = editableweightpsMapper.getWeightByNumber(part2ThirdId, taskId);
                    if (StringUtils.isNotBlank(newWeight3)) {
                        weight3 = pointsCalculate.getPercentInstance(newWeight3);
                    } else {
                        weight3 = pointsCalculate.getPercentInstance(part2InnerObject.getString("weight3"));
                    }

                    String weight4Result = this.getPart2InnerListweight4(checkId, part2ThirdId, weight3, weight4, allweight4);
                    part2InnerMap.put("weight4", weight4Result);

                    List<ProblemCollectDetail> sixthPoints = newProblemCollectDetailMapper.getsixthPoints(checkId, part2FourthId);
                    String pointName6Info = JSON.toJSONString(sixthPoints, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                    JSONArray sixthPointsArray = JSONArray.parseArray(pointName6Info);
                    double calculatePoint6 = 0;
                    double calculateTruePoint = 0;
                    List<Double> calculatePointList = this.calculatePoint6Func(sixthPointsArray, checkId,isNew);
                    calculatePoint6 = calculatePointList.get(1);
                    calculateTruePoint = calculatePointList.get(0);
                    double noProblemPoint = this.calculateNoProblemPointFunc(checkId, part2InnerObject);
                    System.out.println("第六级扣过的分数总分:" + calculatePoint6 + "没有问题的总分:" + noProblemPoint + "第六级总分:" + calculateTruePoint);
                    double checkItemPoint = (calculatePoint6 + noProblemPoint) / (calculateTruePoint + noProblemPoint) * 100;
                    String s = this.getCheckItemPointAndUpdateAllPointSave(checkId, part2FourthId, projectId, checkItemPoint, df);

                    part2InnerMap.put("checkItemPoint", s);
                    point += checkItemPoint * weight3 / (allweight4 / weight4);
                    part2InnerList.add(part2InnerMap);
                }

                List<Object> getThirdId = newProblemCollectDetailMapper.getThirdId(checkId, pName1, secondId);
                String thirdIdInfo = JSON.toJSONString(getThirdId, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray thirdArray = JSONArray.parseArray(thirdIdInfo);

                double allweight3 = 0;
                for (int v = 0; v < thirdArray.size(); v++) {
                    double Tweight3 = 0;
                    int thirdId = thirdArray.getIntValue(v);
                    String newWeight3 = editableweightpsMapper.getWeightByNumber(thirdId, taskId);
                    if (StringUtils.isNotBlank(newWeight3)) {
                        Tweight3 = pointsCalculate.getPercentInstance(newWeight3);
                    } else {
                        String trueweight3 = newprefixsystemMapper.getWeight3ByThirdId(thirdId);
                        Tweight3 = pointsCalculate.getPercentInstance(trueweight3);
                    }
                    allweight3 += Tweight3;
                }
                System.out.println(point + "dasdasdadasd" + allweight3 + "dasdsadsadad" + df.format(point / allweight3));
                double thirdPoint = Double.parseDouble(df.format(point / allweight3));
                double percent2 = Double.parseDouble(df.format(weight222 / allweight2));
                double secondPoint = Double.parseDouble(df.format(thirdPoint * percent2));
                allsecondPoint += secondPoint;
            }

            if (pName1.equals("新安全检查")) {
                dataMap.put("aqPoint", allsecondPoint);
            } else if (pName1.equals("新质量检查")) {
                dataMap.put("zlPoint", allsecondPoint);
            } else if (pName1.equals("新管理行为")) {
                dataMap.put("glPoint", allsecondPoint);
            }
            int firstPointCount = allpointsaveMapper.getAllPointCountByCheckId(checkId, name1Array.getInteger(k));
            if (firstPointCount != 0) {
                SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
                Date date1 = new Date(System.currentTimeMillis());
                String lastEditTime = formatter.format(date1);
                allpointsaveMapper.updateAllPoint(checkId, df.format(allsecondPoint), name1Array.getInteger(k), lastEditTime);
            } else {
                Allpointsave allpointsave = new Allpointsave();
                SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
                Date date1 = new Date(System.currentTimeMillis());
                allpointsave.setNewCreateTime(formatter.format(date1));
                allpointsave.setLastEditTime(formatter.format(date1));
                allpointsave.setCheckId(checkId);
                allpointsave.setNumber(name1Array.getInteger(k));
                allpointsave.setPoint(df.format(allsecondPoint));
                allpointsave.setProjectId(projectId);
                allpointsaveMapper.insert(allpointsave);
            }
            double trueWeight1 = Double.parseDouble(df.format(Tweight1 / allweight1));
            overAllPoint += Double.parseDouble(df.format(trueWeight1 * allsecondPoint));
            part2Map.put("point", allsecondPoint);
            part2Map.put("part2InnerList", part2InnerList);
            part2List.add(part2Map);
        }

        overAllPoint = overAllPoint - allExtraPoint;
        dataMap.put("overAllPoint", overAllPoint);
        //将总分存到ALLPOINTSAVE中
        int allPointInDB = allpointsaveMapper.getAllPointCountByCheckId(checkId, -1);
        if (allPointInDB != 0) {
            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
            Date date1 = new Date(System.currentTimeMillis());
            String lastEditTime = formatter.format(date1);
            allpointsaveMapper.updateAllPoint(checkId, df.format(overAllPoint), -1, lastEditTime);
        } else {
            Allpointsave allpointsave = new Allpointsave();
            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
            Date date1 = new Date(System.currentTimeMillis());
            allpointsave.setNewCreateTime(formatter.format(date1));
            allpointsave.setLastEditTime(formatter.format(date1));
            allpointsave.setCheckId(checkId);
            allpointsave.setNumber(-1);
            allpointsave.setProjectId(projectId);
            allpointsave.setPoint(df.format(overAllPoint));
            allpointsaveMapper.insert(allpointsave);
        }
        //将总分存到CCT表中
        ContractCheckTask contractchecktask = new ContractCheckTask();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
        Date date1 = new Date(System.currentTimeMillis());
        contractchecktask.setLastEditTime(formatter.format(date1));
        contractchecktask.setCheckId(checkId);
        contractchecktask.setTotalPoint(String.valueOf(overAllPoint));
        contractchecktaskMapper.updateByPrimaryKeySelective(contractchecktask);

        List<ProblemCollectDetail> overallList = newProblemCollectDetailMapper.getAllProblemCollectInfoByCheckId(checkId);
        dataMap.put("overAllLever", pointsCalculate.getMaxRiskPoint(overallList));
        ContractTaskProject contracttaskprojectRiskPoint = new ContractTaskProject();
        contracttaskprojectRiskPoint.setProjectId(projectId);
        contracttaskprojectRiskPoint.setLatestRiskLevel(pointsCalculate.getMaxRiskPoint(overallList));
        contracttaskprojectRiskPoint.setLastEditTime(formatter.format(date1));
        contracttaskprojectMapper.updateByPrimaryKeySelective(contracttaskprojectRiskPoint);
        ContractTaskProject newRiskList = contracttaskprojectMapper.selectByPrimaryKey(projectId);
        String finishTime = contractchecktaskMapper.getFinishTimeByCheckId(checkId);
        if (newRiskList.getCheckTime().equals("") || newRiskList.getCheckTime().compareTo(finishTime) <= 0) {
            try {
                ContractTaskProject contracttaskproject = new ContractTaskProject();
                contracttaskproject.setProjectId(projectId);
                contracttaskproject.setLatestCheckTime(finishTime);
                contracttaskproject.setLastEditTime(formatter.format(date1));
                contracttaskprojectMapper.updateByPrimaryKeySelective(contracttaskproject);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        dataMap.put("part2List", part2List);

        //第三部分 问题分布
        List<Object> part3List = new ArrayList<>();
        int allFourthProblem = 0;
        for (int k = 0; k < name1Array.size(); k++) {
            Map<String, Object> part3Map = new HashMap<String, Object>();
            List<Object> part3InnerList = new ArrayList<Object>();
            String pName1 = newprefixsystemMapper.getName4ByName4Id(name1Array.getIntValue(k)); //通过firstId找到pName1
            part3Map.put("name1", pName1);
            List<Object> secondIdList = newProblemCollectDetailMapper.getSecondId(checkId, pName1);  //获取secondIdList
            String secondIdInfo = JSON.toJSONString(secondIdList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
            JSONArray secondIdInfoArray = JSONArray.parseArray(secondIdInfo);
            //计算第四级的问题总数
            DefaultPieDataset datasetProblemPie = new DefaultPieDataset();
            DefaultCategoryDataset datasetProblemBar = new DefaultCategoryDataset();
            allFourthProblem = this.calculateAllFourthProblem(checkId, secondIdInfoArray,isNew);
            part3Map.put("allProblemNum", allFourthProblem);
            List<Double> percentList = new ArrayList<>();
            List<String> name4List = new ArrayList<>();
            for (int n = 0; n < secondIdInfoArray.size(); n++) {
                int secondId = secondIdInfoArray.getIntValue(n);
                List<ProblemCollectDetail> fourthPoints = newProblemCollectDetailMapper.getFourthPoint(checkId, pName1, secondId);
                String fourthCalculateInfo = JSON.toJSONString(fourthPoints, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray fourthPointsCalculateArray = JSONArray.parseArray(fourthCalculateInfo);
                for (int j = 0; j < fourthPointsCalculateArray.size(); j++) {
                    Map<String, Object> part3InnerMap = new HashMap<String, Object>();
                    JSONObject part3InnerObject = fourthPointsCalculateArray.getJSONObject(j);
                    String name4 = part3InnerObject.getString("pName4");
                    part3InnerMap.put("nom", j + 1);
                    part3InnerMap.put("name4", name4);
                    int fourthProblemCount = newProblemCollectDetailMapper.countFourthProblem(checkId, secondId, name4);
                    part3InnerMap.put("problemNum", fourthProblemCount);
                    String percent = pointsCalculate.caculateToPercent(fourthProblemCount, allFourthProblem);
                    part3InnerMap.put("percent", percent);
                    part3InnerList.add(part3InnerMap);
                    datasetProblemPie.setValue(name4 + ":" + percent, new Double(fourthProblemCount));
                    datasetProblemBar.setValue(fourthProblemCount, "各检查分项", name4);
                }
            }

            try {
                JFreeChart chart = ChartFactory.createPieChart("现场施工问题分布饼图",
                        datasetProblemPie,
                        true,
                        true,
                        false);
                final PiePlot plot = (PiePlot) chart.getPlot();
                //设置旋转角度
                plot.setStartAngle(270);
                //设置图表透明图0.0~1.0范围。0.0为完全透明，1.0为完全不透明。
                plot.setForegroundAlpha(0.90f);
                plot.setInteriorGap(0.02);
                chart.getLegend().setVisible(false);
//                File pieChart = new File("E:\\tencent_File\\1296928795\\FileRecv\\" + fileName + "pieChart.png");
                File pieChart = new File("D:\\whutServer\\generatedCharts\\" + fileName + "pieChart.png");
                ChartUtils.saveChartAsPNG(pieChart, chart, width, height);
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                JFreeChart barChart = ChartFactory.createBarChart("现场施工问题分布直方图",
                        "",
                        "数量",
                        datasetProblemBar,
                        PlotOrientation.VERTICAL,
                        true, true, false);
                CategoryPlot plot = (CategoryPlot) barChart.getPlot();
                plot.getRenderer().setSeriesPaint(0, new Color(5, 87, 232));
                BarRenderer barRenderer = (BarRenderer) plot.getRenderer();
                barRenderer.setDefaultItemLabelGenerator(new StandardCategoryItemLabelGenerator());
                barRenderer.setDefaultItemLabelsVisible(true);
                barRenderer.setItemLabelAnchorOffset(-20D);
                barRenderer.setMaximumBarWidth(0.2);
                CategoryAxis categoryAxis = plot.getDomainAxis();
                categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
//                File barChartFile = new File("E:\\tencent_File\\1296928795\\FileRecv\\" + fileName + "barChart.png");
                File barChartFile = new File("D:\\whutServer\\generatedCharts\\" + fileName + "barChart.png");
                ChartUtils.saveChartAsPNG(barChartFile, barChart,  width, height);
            } catch (Exception e) {
                e.printStackTrace();
            }
//            part3Map.put("pieChart",MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\" + fileName + "pieChart.png"));
//            part3Map.put("histogram", MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\" + fileName + "barChart.png"));
            part3Map.put("pieChart", MDoc.getImageStr("D:\\whutServer\\generatedCharts\\" + fileName + "pieChart.png"));
            part3Map.put("histogram", MDoc.getImageStr("D:\\whutServer\\generatedCharts\\" + fileName + "barChart.png"));

            part3Map.put("part3InnerList", part3InnerList);
            part3List.add(part3Map);
        }
        dataMap.put("part3List", part3List);
//        System.out.println("dataMap:"+dataMap);
        //三.检查问题综述
        List<Object> part4List = new ArrayList<Object>();
        for (int i = 0; i < name1Array.size(); i++) {
            List<Object> part4InnerList = new ArrayList<Object>();
            Map<String, Object> part4Map = new HashMap<String, Object>();
            String pName1 = newprefixsystemMapper.getName4ByName4Id(name1Array.getIntValue(i));
            System.out.println("pName1" + pName1);
            List<Summary> summaryList = summaryMapper.getSummaryInfo(checkId, name1Array.getIntValue(i));
            String summaryInfo = JSON.toJSONString(summaryList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
            JSONArray summaryInfoArray = JSONArray.parseArray(summaryInfo);
            for (int j = 0; j < summaryInfoArray.size(); j++) {
                Map<String, Object> part4InnerMap = new HashMap<String, Object>();
                JSONObject part4InnerObject = summaryInfoArray.getJSONObject(j);
                String part4pNname4 = newprefixsystemMapper.getName4ByName4Id(part4InnerObject.getIntValue("fourthId"));
                part4InnerMap.put("pName4", part4pNname4);
                part4InnerMap.put("summary", part4InnerObject.getString("summary"));
                part4InnerList.add(part4InnerMap);
            }
            if (pName1.equals("新安全检查")) {
                part4Map.put("name1", "安全");
            } else if (pName1.equals("新质量检查")) {
                part4Map.put("name1", "质量");
            } else if (pName1.equals("新管理行为")) {
                part4Map.put("name1", "管理");
            }else if (pName1.equals("新设备检查")) {
                part4Map.put("name1", "设备");
            }
            part4Map.put("part4InnerList", part4InnerList);
            part4List.add(part4Map);
        }
        dataMap.put("part4List", part4List);
        //四、（一）风险隐患分布表
        int txNum = newProblemCollectDetailMapper.getAllRiskPointCountByType(checkId, "提醒");
        int oneNum = newProblemCollectDetailMapper.getAllRiskPointCountByType(checkId, "1");
        int twoNum = newProblemCollectDetailMapper.getAllRiskPointCountByType(checkId, "2");
        int threeNum = newProblemCollectDetailMapper.getAllRiskPointCountByType(checkId, "3");
        int fourNum = newProblemCollectDetailMapper.getAllRiskPointCountByType(checkId, "4");
        int allProblemNum = txNum + oneNum + twoNum + threeNum + fourNum;
        dataMap.put("txNum", txNum);
        dataMap.put("oneNum", oneNum);
        dataMap.put("twoNum", twoNum);
        dataMap.put("threeNum", threeNum);
        dataMap.put("fourNum", fourNum);
        dataMap.put("allProblemNum", allProblemNum);
        String txPercent = pointsCalculate.caculateToPercent(txNum, allProblemNum);
        String onePercent = pointsCalculate.caculateToPercent(oneNum, allProblemNum);
        String twoPercent = pointsCalculate.caculateToPercent(twoNum, allProblemNum);
        String threePercent = pointsCalculate.caculateToPercent(threeNum, allProblemNum);
        String fourPercent = pointsCalculate.caculateToPercent(fourNum, allProblemNum);

        dataMap.put("txPercent", txPercent);
        dataMap.put("onePercent", onePercent);
        dataMap.put("twoPercent", twoPercent);
        dataMap.put("threePercent", threePercent);
        dataMap.put("fourPercent", fourPercent);
        //四、（二）风险隐患问题汇总表
        List<Object> partProblemList = new ArrayList<Object>();
        for (int i = 0; i < name1Array.size(); i++) {
            List<Object> partProblemName1List = new ArrayList<Object>();
            Map<String, Object> partProblemMap = new HashMap<String, Object>();
            String pName1 = newprefixsystemMapper.getName4ByName4Id(name1Array.getIntValue(i));
            List<Object> problemName4List = newProblemCollectDetailMapper.getAllName4ByName1(checkId, pName1);
            String problemName4Info = JSON.toJSONString(problemName4List, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
            JSONArray problemName4Array = JSONArray.parseArray(problemName4Info);
            for (int k = 0; k < problemName4Array.size(); k++) {
                List<ProblemCollectDetail> partProblemDetailList = newProblemCollectDetailMapper.getAllFourthInfo(checkId, problemName4Array.getIntValue(k));
                String partProblemDetailInfo = JSON.toJSONString(partProblemDetailList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray partProblemDetailArray = JSONArray.parseArray(partProblemDetailInfo);
                String problemName4 = newprefixsystemMapper.getName4ByName4Id(problemName4Array.getIntValue(k));
                for (int j = 0; j < partProblemDetailArray.size(); j++) {
                    Map<String, Object> partProblemName1Map = new HashMap<String, Object>();
                    JSONObject partProblemObject = partProblemDetailArray.getJSONObject(j);
                    String problemDescription = partProblemObject.getString("problemDescription");
                    String riskPoint = partProblemObject.getString("riskPoint");
                    if (partProblemObject.getString("isRemark").equals("N")) {
                        partProblemName1Map.put("problemDescription", problemDescription);
                    } else if (partProblemObject.getString("isRemark").equals("Y")) {
                        partProblemName1Map.put("problemDescription", partProblemObject.getString("remark"));
                    }
                    partProblemName1Map.put("riskPoint", riskPoint);
                    partProblemName1Map.put("name4", problemName4);
                    partProblemName1List.add(partProblemName1Map);
                }
            }
            if (pName1.equals("新安全检查")) {
                partProblemMap.put("name1", "安全");
            } else if (pName1.equals("新质量检查")) {
                partProblemMap.put("name1", "质量");
            } else if (pName1.equals("新管理行为")) {
                partProblemMap.put("name1", "管理行为");
            }else if(pName1.equals("新设备检查")){
                partProblemMap.put("name1", "管理行为");
            }
            partProblemMap.put("partProblemName1List", partProblemName1List);
            partProblemList.add(partProblemMap);
        }
        dataMap.put("partProblemList", partProblemList);
        //第二部分，各部分工程检查情况
        String section2pName1 = "";
        List<Object> section2List = new ArrayList<Object>();
        for (int b = 0; b < name1Array.size(); b++) {
            Map<String, Object> section2Name1Map = new HashMap<String, Object>();
            List<Object> section2name1List = new ArrayList<Object>();
            String section2name1 = newprefixsystemMapper.getName4ByName4Id(name1Array.getIntValue(b));
            if (section2name1.equals("安全检查")) {
                section2pName1 = "安全问题";
            } else if (section2name1.equals("质量检查")) {
                section2pName1 = "质量问题";
            } else if (section2name1.equals("管理行为")) {
                section2pName1 = "管理体系及管理动作";
            }
            section2Name1Map.put("section2pName1", section2pName1);
            List<Object> section2Name4Info = newProblemCollectDetailMapper.getAllName4ByName1(checkId, section2name1);
            String section2Name44 = JSON.toJSONString(section2Name4Info, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
            JSONArray section2Name4Array = JSONArray.parseArray(section2Name44);
            for (int w = 0; w < section2Name4Array.size(); w++) {
                Map<String, Object> section2Name4Map = new HashMap<String, Object>();
                List<Object> section2Name4List = new ArrayList<Object>();
                int section2Name4Id = section2Name4Array.getIntValue(w);
                String section2Name4 = newprefixsystemMapper.getName4ByName4Id(section2Name4Id);
                List<ProblemCollectDetail> section2Name6Info = newProblemCollectDetailMapper.getAllName6InfoByName4(checkId, section2Name4Id, section2name1);
                String section2Name66 = JSON.toJSONString(section2Name6Info, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray section2Name6Array = JSONArray.parseArray(section2Name66);
                for (int c = 0; c < section2Name6Array.size(); c++) {
                    Map<String, Object> section2Name6Map = new HashMap<String, Object>();
                    List<Object> picList = new ArrayList<Object>();
                    JSONObject section2Name6Object = section2Name6Array.getJSONObject(c);
                    section2Name6Map.put("section2pName6No", c + 1);
                    section2Name6Map.put("section2pName6", section2Name6Object.getString("pName6"));
                    section2Name6Map.put("section2pName5", section2Name6Object.getString("pName5"));
                    section2Name6Map.put("section2RiskLevel", section2Name6Object.getString("riskPoint"));
                    section2Name6Map.put("section2CheckPart", section2Name6Object.getString("checkPart"));
                    section2Name6Map.put("section2ProblemNum", section2Name6Object.getString("problemQua"));
                    if (section2Name6Object.getString("isRemark").equals("N")) {
                        section2Name6Map.put("section2problemDescription", section2Name6Object.getString("problemDescription"));
                    } else if (section2Name6Object.getString("isRemark").equals("Y")) {
                        section2Name6Map.put("section2problemDescription", section2Name6Object.getString("remark"));
                    }
                    section2Name6Map.put("section2normsProvison", section2Name6Object.getString("normsProvison"));
                    section2Name6Map.put("section2suggestion", section2Name6Object.getString("suggestion"));
                    String section2picPath = section2Name6Object.getString("picPath");
                    String picName = section2Name6Object.getString("picName");
                    JSONArray ja = JSONArray.parseArray(picName);
                    if (ja.size() == 0) {
//                        String s = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                        String s = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                        picList.add(s);
                    } else {
                        for (int o = 0; o < ja.size(); o++) {
                            String imgFilePath = section2picPath + ja.getString(o);
                            if (!MDoc.isFoundImageStr(imgFilePath)) {
                                imgFilePath = "D:\\whutServer\\generatedCharts\\test.png";
                            }
                            String s = MDoc.getImageStr(imgFilePath);
//                            String s = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                            picList.add(s);
                        }
                    }
                    section2Name6Map.put("picList", picList);
                    section2Name4List.add(section2Name6Map);

                }
                section2Name4Map.put("section2pName4", section2Name4);
                section2Name4Map.put("section2Name4List", section2Name4List);
                section2name1List.add(section2Name4Map);
            }
            section2Name1Map.put("section2Name1List", section2name1List);
            section2List.add(section2Name1Map);
        }
        dataMap.put("section2List", section2List);
        MDoc mdoc = new MDoc();
        String path = FileUtil.getServerFolderPath();
        File f1 = new File(path, "doc");
        if (!f1.exists()) {
            f1.mkdirs();
        }
        //System.out.println("dataMap:"+dataMap);
        String result = "";
//        mdoc.createDoc(dataMap, "E:\\tencent_File\\1296928795\\FileRecv\\yirui\\" + contractTaskProject.getString("projectName").replace('#','号')+"建设局综合检查报告"+fileName + ".doc", "ftl\\constructionMulCheckReport.ftl");
//        MDoc.docToDocx("E:\\tencent_File\\1296928795\\FileRecv\\yirui\\" + contractTaskProject.getString("projectName").replace('#','号')+"建设局综合检查报告"+fileName + ".doc", "E:\\tencent_File\\1296928795\\FileRecv\\yirui" + contractTaskProject.getString("projectName").replace('#','号')+"建设局综合检查报告"+fileName + ".doc");
//        result = "E:\\tencent_File\\1296928795\\FileRecv\\yirui\\" + contractTaskProject.getString("projectName").replace('#','号')+"建设局综合检查报告"+fileName + ".doc";
        mdoc.createDoc(dataMap, path + "\\doc\\" + String.valueOf(dataMap.get("projectName")).replace('#', '号') + "建设局综合检查报告" + fileName + ".doc", "ftl\\constructionMulCheckReport.ftl");
        //MDoc.docToDocx("D:\\whutServer\\apache-tomcat-8.5.41\\webapps\\ROOT\\doc\\" + contractTaskProject.getString("projectName").replace('#','号')+"建设局综合检查报告"+fileName + ".doc", "D:\\whutServer\\apache-tomcat-8.5.41\\webapps\\ROOT\\doc\\" + contractTaskProject.getString("projectName").replace('#','号')+"建设局综合检查报告"+fileName + ".doc");
        result = urlProperties.getAddress() + "/doc/" + String.valueOf(dataMap.get("projectName")).replace('#', '号').replace('#', '号') + "建设局综合检查报告" + fileName + ".doc";
        return result;
    }



    /**
     * @author: liukang
     * @Description: 市政设备专项评估报告，reportType=8255
     * @date: 2020/9/9 19:26
     * @param:
     * @return:
     */
    public String cityEquipAssessReport(int checkId, int projectId, int reportType) {

        //dataMap存储报告中的所有数据
        CityEquipAssessDataMap dataMap = new CityEquipAssessDataMap();

        //报告日期和报告命名需要的时间信息
        DateTimeFormatter dateFormatterYear = DateTimeFormatter.ofPattern("yyyy");
        String year = dateFormatterYear.format(LocalDate.now());
        dataMap.setYear(year);
        DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日");
        String reportDate = dateFormatter.format(LocalDate.now());
        dataMap.setReportDate(reportDate);

        //第一部分 ----- 一、工程概况
        ContractTaskProject projectInfo = contracttaskprojectMapper.getProjectInfoByProjectId(projectId);
        dataMap.setProjectName(projectInfo.getProjectName());
        dataMap.setJsUnit(projectInfo.getJsUnit());
        dataMap.setJlUnit(projectInfo.getJlUnit());
        dataMap.setSgUnit(projectInfo.getSgUnit());

        //第一部分 ----- 二、评估结果 ----- （一）设备专项评估结果
        //计算设备得分
        List<sbzxPart2Seg1Map> sbzxPart2Seg1MapList = machineinfoMapper.getEquipNumberInfo(projectId);
        //记录各个专业的问题分布
        List<wtfbPart2Seg2Map> wtfbPart2Seg2MapList = new LinkedList<>();
        int wtfbNumber = 1;
        for (sbzxPart2Seg1Map sbzxPart2Seg1MapItem : sbzxPart2Seg1MapList) {

            //问题分布的相关信息
            wtfbPart2Seg2Map wtfbPart2Seg2MapItem = new wtfbPart2Seg2Map();
            wtfbPart2Seg2MapItem.setWtfbNumber(wtfbNumber++);
            wtfbPart2Seg2MapItem.setWtfbType(sbzxPart2Seg1MapItem.getSbzxName());
            int wtfbNum = 0;

            List<sbzxPart2Seg1InnerMap> sbzxPart2Seg1InnerMapList = sbzxPart2Seg1MapItem.getSbzxPart2Seg1InnerList();
            //计算每台设备得分
            for (sbzxPart2Seg1InnerMap sbzxPart2Seg1InnerMapItem : sbzxPart2Seg1InnerMapList) {

                //算有问题项的得分（checkpart存的是equipNum，设备编号
                List<Map<String, Double>> scoreList = new LinkedList<>();
                List<ProblemCollectDetail> problemList = problemCollectDetailMapper.getEquipProblems(sbzxPart2Seg1InnerMapItem.getSbzxEquipName(), checkId, sbzxPart2Seg1MapItem.getMachineType());
                for (ProblemCollectDetail problemCollectDetail : problemList) {
                    Map<String, Double> problemScoreMap = new HashMap<>();
                    problemScoreMap.put("deductScore", Double.parseDouble(problemCollectDetail.getPoint6()) - Double.parseDouble(problemCollectDetail.getReducePoint()));
                    problemScoreMap.put("totalScore", Double.parseDouble(problemCollectDetail.getPoint6()));
                    scoreList.add(problemScoreMap);
                }
                //记录问题数量
                wtfbNum = wtfbNum + problemList.size();

                //计算无问题项的得分
                List<Integer> noProblemNum = noproblemitemMapper.getNoProblemSixId(sbzxPart2Seg1InnerMapItem.getSbzxEquipName(), checkId, sbzxPart2Seg1MapItem.getMachineType());
                for (Integer noProblemNumItem : noProblemNum) {
                    double noProblemNumScore = Double.parseDouble(prefixsystemMapper.getPoint4ByPoint4Id(noProblemNumItem));
                    Map<String, Double> noProblemScoreMap = new HashMap<>();
                    noProblemScoreMap.put("deductScore", noProblemNumScore);
                    noProblemScoreMap.put("totalScore", noProblemNumScore);
                    scoreList.add(noProblemScoreMap);
                }

                //计算每台设备的最终得分
                Map<String, Double> scoreResultMap = scoreList.stream()
                        .reduce(new HashMap<String, Double>(), (res, item) -> {
                            res.put("deductScore", res.getOrDefault("deductScore", (double) 0) + item.get("deductScore"));
                            res.put("totalScore", res.getOrDefault("totalScore", (double) 0) + item.get("totalScore"));
                            return res;
                        });
                double singleEquipScore = scoreResultMap.get("deductScore") / scoreResultMap.get("totalScore") * 100;
                sbzxPart2Seg1InnerMapItem.setSbzxEquipScore((double) Math.round(singleEquipScore * 100) / 100);
            }
            //计算平均分，得分项得分
            double equipScore = sbzxPart2Seg1InnerMapList.stream()
                    .mapToDouble(sbzxPart2Seg1InnerMap::getSbzxEquipScore)
                    .average()
                    .getAsDouble();
            sbzxPart2Seg1MapItem.setSbzxScore((double) Math.round(equipScore * 100) / 100);

            //获取初步的权重,如果是房建设备拿不到权重的
            for (EquipReportWeightEnum equipReportWeightEnum : EquipReportWeightEnum.values()) {
                if (StringUtils.equals(sbzxPart2Seg1MapItem.getSbzxName(), equipReportWeightEnum.getSbzxName())) {
                    sbzxPart2Seg1MapItem.setSbzxWeightInteger(equipReportWeightEnum.getSbzxWeight());
                }
            }
            wtfbPart2Seg2MapItem.setWtfbNum(wtfbNum);
            wtfbPart2Seg2MapList.add(wtfbPart2Seg2MapItem);
        }
        //根据分项结果计算分项权重，并计算设备专项得分
        int sbzxTotalWeight = sbzxPart2Seg1MapList.stream()
                .mapToInt(sbzxPart2Seg1Map::getSbzxWeightInteger)
                .sum();
        double sbzxScore = 0;
        for (sbzxPart2Seg1Map sbzxPart2Seg1MapItem : sbzxPart2Seg1MapList) {
            String sbzxWeight = calculatePercent(sbzxPart2Seg1MapItem.getSbzxWeightInteger(), sbzxTotalWeight);
            sbzxPart2Seg1MapItem.setSbzxWeight(sbzxWeight);
            sbzxScore += sbzxPart2Seg1MapItem.getSbzxScore() * sbzxPart2Seg1MapItem.getSbzxWeightInteger() / sbzxTotalWeight;
        }
        dataMap.setSbzxScore((double) (Math.round(sbzxScore * 100) * 1.0 / 100));
        dataMap.setSbzxPart2Seg1List(sbzxPart2Seg1MapList);

        //第一部分 ----- 二、评估结果 ----- （二）各个专业的问题分布
        //在计算设备专项评估结果的过程中进行了计数
        //过滤问题数量为0的数据（用filter和forEach也可以）
        for (int i = 0; i < wtfbPart2Seg2MapList.size(); i++) {
            if (wtfbPart2Seg2MapList.get(i).getWtfbNum() == 0) {
                wtfbPart2Seg2MapList.remove(i);
            }
        }
        int wtfbNumSum = wtfbPart2Seg2MapList.stream()
                .mapToInt(wtfbPart2Seg2Map::getWtfbNum)
                .sum();
        for (wtfbPart2Seg2Map wtfbPart2Seg2MapItem : wtfbPart2Seg2MapList) {
            String wtfbPercent = calculatePercent(wtfbPart2Seg2MapItem.getWtfbNum(), wtfbNumSum);
            wtfbPart2Seg2MapItem.setWtfbPercent(wtfbPercent);
        }
        dataMap.setWtfbNumSum(wtfbNumSum);
        dataMap.setWtfbPart2Seg2List(wtfbPart2Seg2MapList);

        //第一部分 ----- 二、评估结果 ----- （三）设备信息及检查情况
        List<jcqkPart2Seg3Map> jcqkPart2Seg3MapList = machineinfoMapper.getEquipUnitInfo(projectId);
        //计算设备数量
        for (jcqkPart2Seg3Map jcqkPart2Seg3MapItem : jcqkPart2Seg3MapList) {
            int jcqkEquipNum = 0;
            for (jcqkPart2Seg3Inner1Map jcqkPart2Seg3Inner1MapItem : jcqkPart2Seg3MapItem.getJcqkPart2Seg3Inner1List()) {
                jcqkEquipNum = jcqkEquipNum + jcqkPart2Seg3Inner1MapItem.getJcqkPart2Seg3Inner2List().size();
            }
            jcqkPart2Seg3MapItem.setJcqkEquipNum(jcqkEquipNum);
        }
        //计算3、4级隐患数量
        List<jcqkPart2Seg3Inner2Map> jcqkPart2Seg3Inner2MapList = machineinfoMapper.getEquipRiskNum(checkId, projectId);
        for (jcqkPart2Seg3Map jcqkPart2Seg3MapItem : jcqkPart2Seg3MapList) {
            for (jcqkPart2Seg3Inner1Map jcqkPart2Seg3Inner1MapItem : jcqkPart2Seg3MapItem.getJcqkPart2Seg3Inner1List()) {
                for (jcqkPart2Seg3Inner2Map jcqkPart2Seg3Inner2MapItem : jcqkPart2Seg3Inner1MapItem.getJcqkPart2Seg3Inner2List()) {

                    for (jcqkPart2Seg3Inner2Map jcqkPart2Seg3Inner2MapRiskItem : jcqkPart2Seg3Inner2MapList) {
                        if (StringUtils.equals(jcqkPart2Seg3Inner2MapRiskItem.getJcqkEquipCode(), jcqkPart2Seg3Inner2MapItem.getJcqkEquipCode())) {
                            jcqkPart2Seg3Inner2MapItem.setJcqkLevel3Num(jcqkPart2Seg3Inner2MapRiskItem.getJcqkLevel3Num());
                            jcqkPart2Seg3Inner2MapItem.setJcqkLevel4Num(jcqkPart2Seg3Inner2MapRiskItem.getJcqkLevel4Num());
                        }
                    }
                }
            }
        }
        //合计隐患数量
        for (jcqkPart2Seg3Map jcqkPart2Seg3MapItem : jcqkPart2Seg3MapList) {
            for (jcqkPart2Seg3Inner1Map jcqkPart2Seg3Inner1MapItem : jcqkPart2Seg3MapItem.getJcqkPart2Seg3Inner1List()) {
                int jcqkLevel3NumSum = jcqkPart2Seg3Inner1MapItem.getJcqkPart2Seg3Inner2List()
                        .stream()
                        .mapToInt(jcqkPart2Seg3Inner2Map::getJcqkLevel3Num)
                        .sum();
                int jcqkLevel4NumSum = jcqkPart2Seg3Inner1MapItem.getJcqkPart2Seg3Inner2List()
                        .stream()
                        .mapToInt(jcqkPart2Seg3Inner2Map::getJcqkLevel4Num)
                        .sum();
                jcqkPart2Seg3Inner1MapItem.setJcqkLevel3NumSum(jcqkLevel3NumSum);
                jcqkPart2Seg3Inner1MapItem.setJcqkLevel4NumSum(jcqkLevel4NumSum);
            }
        }
        dataMap.setJcqkPart2Seg3List(jcqkPart2Seg3MapList);

        //第一部分 ----- 二、评估结果 ----- （四）隐患分布表
        EquipRiskNumVO equipRiskNumSum = machineinfoMapper.getEquipRiskNumSum(checkId, projectId);
        BeanUtil.copyProperties(equipRiskNumSum, dataMap, CopyOptions.create().setIgnoreNullValue(true));
        //BeanUtils.copyProperties(equipRiskNumSum,dataMap);
        //计算百分比和隐患合计数量
        if (equipRiskNumSum != null) {
            int yhfbNumSum = equipRiskNumSum.getYhfb0Num() + equipRiskNumSum.getYhfb1Num() + equipRiskNumSum.getYhfb2Num() + equipRiskNumSum.getYhfb3Num() + equipRiskNumSum.getYhfb4Num();
            dataMap.setYhfbNumSum(yhfbNumSum);
            dataMap.setYhfb0Percent(calculatePercent(equipRiskNumSum.getYhfb0Num(), yhfbNumSum));
            dataMap.setYhfb1Percent(calculatePercent(equipRiskNumSum.getYhfb1Num(), yhfbNumSum));
            dataMap.setYhfb2Percent(calculatePercent(equipRiskNumSum.getYhfb2Num(), yhfbNumSum));
            dataMap.setYhfb3Percent(calculatePercent(equipRiskNumSum.getYhfb3Num(), yhfbNumSum));
            dataMap.setYhfb4Percent(calculatePercent(equipRiskNumSum.getYhfb4Num(), yhfbNumSum));
        }

        //第一部分 ----- 三、问题汇总表
        List<wthzPart3Map> wthzPart3MapList = machineinfoMapper.getEquipProblemInfo(checkId, projectId);
        dataMap.setWthzPart3List(wthzPart3MapList);

        //第一部分 ----- 四、安全情况及改进建议
        List<glgjPart4Map> glgjPart4MapList = machineinfoMapper.getProblemSummaryInfo(checkId, projectId);

        List<glgjPart4Map> glgjPart4MapListDistinct = glgjPart4MapList.stream().distinct().collect(Collectors.toList());

        //处理结果展示形式，相同设备合并改进建议
        Map<String, String[]> glgjMap = new HashMap<>();
        for (int i = 0; i < glgjPart4MapListDistinct.size(); i++) {
            glgjPart4Map glgjPart4MapItem = glgjPart4MapListDistinct.get(i);
            glgjPart4Map glgjPart4MapItemPre = new glgjPart4Map(1, "test", "test", "test");
            if (i >= 1) {
                glgjPart4MapItemPre = glgjPart4MapListDistinct.get(i - 1);
            }
            if (glgjMap.get(glgjPart4MapItem.getGlgjType()) != null) {
                String[] tmpStr = new String[2];
                if (glgjPart4MapItem.getGlgjSituation() != null && glgjPart4MapItem.getGlgjSituation() != "null" && !StringUtils.equals(glgjPart4MapItem.getGlgjSituation(), glgjPart4MapItemPre.getGlgjSituation())) {
                    tmpStr[0] = glgjMap.get(glgjPart4MapItem.getGlgjType())[0] + "  \r\n  " + glgjPart4MapItem.getGlgjSituation();
                }
                if (glgjPart4MapItem.getGlgjSuggestion() != null && glgjPart4MapItem.getGlgjSuggestion() != "null") {
                    tmpStr[1] = glgjMap.get(glgjPart4MapItem.getGlgjType())[1] + "  \r\n  " + glgjPart4MapItem.getGlgjSuggestion();
                }
                glgjMap.put(glgjPart4MapItem.getGlgjType(), tmpStr);

            } else {
                String[] tmpStr = new String[2];
                tmpStr[0] = "    " + glgjPart4MapItem.getGlgjSituation();
                tmpStr[1] = "    " + glgjPart4MapItem.getGlgjSuggestion();
                glgjMap.put(glgjPart4MapItem.getGlgjType(), tmpStr);
            }
        }
        List<glgjPart4Map> newglgjPart4MapList = new LinkedList<>();
        int index = 1;
        for (String key : glgjMap.keySet()) {
            //String situation = StringUtils.isBlank(glgjMap.get(key)[0]) ? "    暂无风险" : glgjMap.get(key)[0];
            String situation = "手动填入";
            String summary = StringUtils.isBlank(glgjMap.get(key)[1]) ? "    暂无小结" : glgjMap.get(key)[1];
            glgjPart4Map tmp = new glgjPart4Map(index, key, situation, summary);
            newglgjPart4MapList.add(tmp);
            index++;
        }

        dataMap.setGlgjPart4List(newglgjPart4MapList);

        //第二部分 各分项工程检查情况
        List<section2Map> section2MapList = machineinfoMapper.getEquipCheckResultInfo(checkId, projectId);
        //处理序号和图片地址
        for (section2Map section2MapItem : section2MapList) {
            for (int i = 0; i < section2MapItem.getSection2Inner1List().size(); i++) {
                section2Inner1Map section2Inner1MapItem = section2MapItem.getSection2Inner1List().get(i);
                //序号
                section2Inner1MapItem.setSection2Number(i + 1);
                //图片
                List<String> section2ImageMapList = new LinkedList<>();
                JSONArray section2picNameArray = JSONArray.parseArray(section2Inner1MapItem.getSection2PicName());
                if (section2picNameArray == null || section2picNameArray.size() == 0) {
                    //todo 报告本地测试
                    //String s = MDoc.getImageStr("D:\\Work\\LabWork\\YiRui\\文档\\Test\\Pic\\noPic.png");
                    String s = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                    section2ImageMapList.add(s);
                } else {
                    for (int j = 0; j < section2picNameArray.size(); j++) {
                        //todo 报告本地测试
                        //String s = MDoc.getImageStr("D:\\Work\\LabWork\\YiRui\\文档\\Test\\Pic\\noPic.png");
                        String s = MDoc.getImageStr(section2Inner1MapItem.getSection2PicPath() + section2picNameArray.getString(j));
                        section2ImageMapList.add(s);
                    }
                }
                section2Inner1MapItem.setSection2ImageList(section2ImageMapList);
            }
        }
        dataMap.setSection2List(section2MapList);

        //生成报告
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyyMMddhhmmss");
        String fileNameTime = dateTimeFormatter.format(LocalDateTime.now());
        String reportName = projectInfo.getProjectName().replace('#', '号') + "市政设备专项评估报告" + fileNameTime;
        String ftlName = "cityEquipAssessReport";

        BeanMap beanMap = new BeanMap(dataMap);

        return generateReport(beanMap, reportName, ftlName);

    }

    /**
     * @author: liukang
     * @Description: 房建设备专项评估报告，reportType=8256
     * @date: 2020/9/9 19:26
     * @param:
     * @return:
     */
    public String houseEquipAssessReport(int checkId, int projectId, int reportType) {

        //dataMap存储报告中的所有数据
        HouseEquipAssessDataMap dataMap = new HouseEquipAssessDataMap();

        //报告日期和报告命名需要的时间信息
        DateTimeFormatter dateFormatterYear = DateTimeFormatter.ofPattern("yyyy");
        String year = dateFormatterYear.format(LocalDate.now());
        dataMap.setYear(year);
        DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日");
        String reportDate = dateFormatter.format(LocalDate.now());
        dataMap.setReportDate(reportDate);

        //第一部分 ----- 一、工程概况
        ContractTaskProject projectInfo = contracttaskprojectMapper.getProjectInfoByProjectId(projectId);
        dataMap.setProjectName(projectInfo.getProjectName());
        dataMap.setJsUnit(projectInfo.getJsUnit());
        dataMap.setJlUnit(projectInfo.getJlUnit());
        dataMap.setSgUnit(projectInfo.getSgUnit());

        //第一部分 ----- 二、评估结果 ----- （一）设备专项评估结果

        List<sbzxPart2Seg1Map> sbzxPart2Seg1MapList = machineinfoMapper.getEquipNumberInfo(projectId);
        //记录各个专业的问题分布
        List<wtfbPart2Seg2Map> wtfbPart2Seg2MapList = new LinkedList<>();
        int wtfbNumber = 1;
        for (sbzxPart2Seg1Map sbzxPart2Seg1MapItem : sbzxPart2Seg1MapList) {

            //问题分布的相关信息
            wtfbPart2Seg2Map wtfbPart2Seg2MapItem = new wtfbPart2Seg2Map();
            wtfbPart2Seg2MapItem.setWtfbNumber(wtfbNumber++);
            wtfbPart2Seg2MapItem.setWtfbType(sbzxPart2Seg1MapItem.getSbzxName());
            int wtfbNum = 0;

            List<sbzxPart2Seg1InnerMap> sbzxPart2Seg1InnerMapList = sbzxPart2Seg1MapItem.getSbzxPart2Seg1InnerList();
            //计算每台设备得分
            for (sbzxPart2Seg1InnerMap sbzxPart2Seg1InnerMapItem : sbzxPart2Seg1InnerMapList) {

                //算有问题项的得分
                List<Map<String, Double>> scoreList = new LinkedList<>();
                List<ProblemCollectDetail> problemList = problemCollectDetailMapper.getEquipProblems(sbzxPart2Seg1InnerMapItem.getSbzxEquipName(), checkId, sbzxPart2Seg1MapItem.getMachineType());
                for (ProblemCollectDetail problemCollectDetail : problemList) {
                    Map<String, Double> problemScoreMap = new HashMap<>();
                    problemScoreMap.put("deductScore", Double.parseDouble(problemCollectDetail.getPoint6()) - Double.parseDouble(problemCollectDetail.getReducePoint()));
                    problemScoreMap.put("totalScore", Double.parseDouble(problemCollectDetail.getPoint6()));
                    scoreList.add(problemScoreMap);
                }
                //记录问题数量
                wtfbNum = wtfbNum + problemList.size();

                //计算无问题项的得分
                List<Integer> noProblemNum = noproblemitemMapper.getNoProblemSixId(sbzxPart2Seg1InnerMapItem.getSbzxEquipName(), checkId, sbzxPart2Seg1MapItem.getMachineType());
                for (Integer noProblemNumItem : noProblemNum) {
                    double noProblemNumScore = Double.parseDouble(prefixsystemMapper.getPoint4ByPoint4Id(noProblemNumItem));
                    Map<String, Double> noProblemScoreMap = new HashMap<>();
                    noProblemScoreMap.put("deductScore", noProblemNumScore);
                    noProblemScoreMap.put("totalScore", noProblemNumScore);
                    scoreList.add(noProblemScoreMap);
                }

                //计算每台设备的最终得分
                Map<String, Double> scoreResultMap = scoreList.stream()
                        .reduce(new HashMap<String, Double>(), (res, item) -> {
                            res.put("deductScore", res.getOrDefault("deductScore", (double) 0) + item.get("deductScore"));
                            res.put("totalScore", res.getOrDefault("totalScore", (double) 0) + item.get("totalScore"));
                            return res;
                        });
                double singleEquipScore = scoreResultMap.get("deductScore") / scoreResultMap.get("totalScore") * 100;
                sbzxPart2Seg1InnerMapItem.setSbzxEquipScore((double) Math.round(singleEquipScore * 100) / 100);
            }
            //计算平均分，得分项得分
            double equipScore = sbzxPart2Seg1InnerMapList.stream()
                    .mapToDouble(sbzxPart2Seg1InnerMap::getSbzxEquipScore)
                    .average()
                    .getAsDouble();
            sbzxPart2Seg1MapItem.setSbzxScore((double) Math.round(equipScore * 100) / 100);

            wtfbPart2Seg2MapItem.setWtfbNum(wtfbNum);
            wtfbPart2Seg2MapList.add(wtfbPart2Seg2MapItem);
        }

        //房建报告不同于市政报告的地方
        //计算权重和分数要根据具体情况进行计算（这写法整复杂了,不如直接写sql
        Map<Boolean, List<sbzxPart2Seg1Map>> sbzxPart2Seg1MapList02 = sbzxPart2Seg1MapList.stream()
                .collect(Collectors.groupingBy(a -> StringUtils.equals(a.getSbzxName(), "施工升降机") || StringUtils.equals(a.getSbzxName(), "物料提升机")));

        List<sbzxPart2Seg1Map> sbzxPart2Seg1MapListsjj = sbzxPart2Seg1MapList02.get(true);
        List<sbzxPart2Seg1Map> sbzxPart2Seg1MapListqzj = sbzxPart2Seg1MapList02.get(false);
        double sbzxScore01 = 0;
        if (sbzxPart2Seg1MapListqzj != null && sbzxPart2Seg1MapListqzj.size() == 1) {
            sbzxPart2Seg1Map sbzxPart2Seg1MapItem = sbzxPart2Seg1MapListqzj.get(0);
            sbzxPart2Seg1MapItem.setSbzxWeight("100%");
            sbzxScore01 = sbzxScore01 + sbzxPart2Seg1MapItem.getSbzxScore();
        } else if (sbzxPart2Seg1MapListqzj != null && sbzxPart2Seg1MapList02.get(false).size() == 2) {
            for (sbzxPart2Seg1Map sbzxPart2Seg1MapItem : sbzxPart2Seg1MapListqzj) {
                if (StringUtils.equals(sbzxPart2Seg1MapItem.getSbzxName(), "塔式起重机")) {
                    sbzxPart2Seg1MapItem.setSbzxWeight("60%");
                    sbzxScore01 = sbzxScore01 + sbzxPart2Seg1MapItem.getSbzxScore() * 0.6;
                } else {
                    sbzxPart2Seg1MapItem.setSbzxWeight("40%");
                    sbzxScore01 = sbzxScore01 + sbzxPart2Seg1MapItem.getSbzxScore() * 0.4;
                }
            }
        }
        double sbzxScore02 = 0;
        if (sbzxPart2Seg1MapListsjj != null && sbzxPart2Seg1MapListsjj.size() == 1) {
            sbzxPart2Seg1Map sbzxPart2Seg1MapItem = sbzxPart2Seg1MapListsjj.get(0);
            sbzxPart2Seg1MapItem.setSbzxWeight("100%");
            sbzxScore02 = sbzxScore02 + sbzxPart2Seg1MapItem.getSbzxScore();
        } else if (sbzxPart2Seg1MapListsjj != null && sbzxPart2Seg1MapListsjj.size() == 2) {
            for (sbzxPart2Seg1Map sbzxPart2Seg1MapItem : sbzxPart2Seg1MapListsjj) {
                if (StringUtils.equals(sbzxPart2Seg1MapItem.getSbzxName(), "施工升降机")) {
                    sbzxPart2Seg1MapItem.setSbzxWeight("60%");
                    sbzxScore02 = sbzxScore02 + sbzxPart2Seg1MapItem.getSbzxScore() * 0.6;
                } else if (StringUtils.equals(sbzxPart2Seg1MapItem.getSbzxName(), "物料提升机")) {
                    sbzxPart2Seg1MapItem.setSbzxWeight("40%");
                    sbzxScore02 = sbzxScore02 + sbzxPart2Seg1MapItem.getSbzxScore() * 0.4;
                }
            }
        }

        List<sbzxPart2Seg1PreMap> sbzxPart2Seg1PreList = new LinkedList<>();
        double sbzxScore = 0;
        if (sbzxPart2Seg1MapListsjj != null && sbzxPart2Seg1MapListsjj.size() != 0 && sbzxPart2Seg1MapListqzj != null && sbzxPart2Seg1MapListqzj.size() != 0) {
            sbzxScore = sbzxScore01 * 0.5 + sbzxScore02 * 0.5;
            sbzxPart2Seg1PreMap sbzxPart2Seg1PreMapItem01 = new sbzxPart2Seg1PreMap("塔式起重机与起重吊装", "50%", sbzxPart2Seg1MapListqzj);
            sbzxPart2Seg1PreMap sbzxPart2Seg1PreMapItem02 = new sbzxPart2Seg1PreMap("施工升降机与物料提升机", "50%", sbzxPart2Seg1MapListsjj);
            sbzxPart2Seg1PreList.add(sbzxPart2Seg1PreMapItem01);
            sbzxPart2Seg1PreList.add(sbzxPart2Seg1PreMapItem02);
        } else if (sbzxPart2Seg1MapListsjj != null && sbzxPart2Seg1MapListsjj.size() != 0 && (sbzxPart2Seg1MapListqzj == null || sbzxPart2Seg1MapListqzj.size() == 0)) {
            sbzxScore = sbzxScore02;
            sbzxPart2Seg1PreMap sbzxPart2Seg1PreMapItem02 = new sbzxPart2Seg1PreMap("施工升降机与物料提升机", "100%", sbzxPart2Seg1MapListsjj);
            sbzxPart2Seg1PreList.add(sbzxPart2Seg1PreMapItem02);
        } else if ((sbzxPart2Seg1MapListsjj == null || sbzxPart2Seg1MapListsjj.size() == 0) && sbzxPart2Seg1MapListqzj != null && sbzxPart2Seg1MapListqzj.size() != 0) {
            sbzxScore = sbzxScore01;
            sbzxPart2Seg1PreMap sbzxPart2Seg1PreMapItem01 = new sbzxPart2Seg1PreMap("塔式起重机与起重吊装", "100%", sbzxPart2Seg1MapListqzj);
            sbzxPart2Seg1PreList.add(sbzxPart2Seg1PreMapItem01);
        }

        dataMap.setSbzxScore((double) (Math.round(sbzxScore * 100) * 1.0 / 100));
        dataMap.setSbzxPart2Seg1PreList(sbzxPart2Seg1PreList);

        //第一部分 ----- 二、评估结果 ----- （二）各个专业的问题分布
        //在计算设备专项评估结果的过程中进行了计数
        //过滤问题数量为0的数据（用filter和forEach也可以）
        for (int i = 0; i < wtfbPart2Seg2MapList.size(); i++) {
            if (wtfbPart2Seg2MapList.get(i).getWtfbNum() == 0) {
                wtfbPart2Seg2MapList.remove(i);
            }
        }
        int wtfbNumSum = wtfbPart2Seg2MapList.stream()
                .mapToInt(wtfbPart2Seg2Map::getWtfbNum)
                .sum();
        for (wtfbPart2Seg2Map wtfbPart2Seg2MapItem : wtfbPart2Seg2MapList) {
            String wtfbPercent = calculatePercent(wtfbPart2Seg2MapItem.getWtfbNum(), wtfbNumSum);
            wtfbPart2Seg2MapItem.setWtfbPercent(wtfbPercent);
        }
        dataMap.setWtfbNumSum(wtfbNumSum);
        dataMap.setWtfbPart2Seg2List(wtfbPart2Seg2MapList);

        //第一部分 ----- 二、评估结果 ----- （三）设备信息及检查情况
        List<jcqkPart2Seg3Map> jcqkPart2Seg3MapList = machineinfoMapper.getEquipUnitInfo(projectId);
        //计算设备数量
        for (jcqkPart2Seg3Map jcqkPart2Seg3MapItem : jcqkPart2Seg3MapList) {
            int jcqkEquipNum = 0;
            for (jcqkPart2Seg3Inner1Map jcqkPart2Seg3Inner1MapItem : jcqkPart2Seg3MapItem.getJcqkPart2Seg3Inner1List()) {
                jcqkEquipNum = jcqkEquipNum + jcqkPart2Seg3Inner1MapItem.getJcqkPart2Seg3Inner2List().size();
            }
            jcqkPart2Seg3MapItem.setJcqkEquipNum(jcqkEquipNum);
        }
        //计算3、4级隐患数量
        List<jcqkPart2Seg3Inner2Map> jcqkPart2Seg3Inner2MapList = machineinfoMapper.getEquipRiskNum(checkId, projectId);
        for (jcqkPart2Seg3Map jcqkPart2Seg3MapItem : jcqkPart2Seg3MapList) {
            for (jcqkPart2Seg3Inner1Map jcqkPart2Seg3Inner1MapItem : jcqkPart2Seg3MapItem.getJcqkPart2Seg3Inner1List()) {
                for (jcqkPart2Seg3Inner2Map jcqkPart2Seg3Inner2MapItem : jcqkPart2Seg3Inner1MapItem.getJcqkPart2Seg3Inner2List()) {

                    for (jcqkPart2Seg3Inner2Map jcqkPart2Seg3Inner2MapRiskItem : jcqkPart2Seg3Inner2MapList) {
                        if (StringUtils.equals(jcqkPart2Seg3Inner2MapRiskItem.getJcqkEquipCode(), jcqkPart2Seg3Inner2MapItem.getJcqkEquipCode())) {
                            jcqkPart2Seg3Inner2MapItem.setJcqkLevel3Num(jcqkPart2Seg3Inner2MapRiskItem.getJcqkLevel3Num());
                            jcqkPart2Seg3Inner2MapItem.setJcqkLevel4Num(jcqkPart2Seg3Inner2MapRiskItem.getJcqkLevel4Num());
                        }
                    }
                }
            }
        }
        //合计隐患数量
        for (jcqkPart2Seg3Map jcqkPart2Seg3MapItem : jcqkPart2Seg3MapList) {
            for (jcqkPart2Seg3Inner1Map jcqkPart2Seg3Inner1MapItem : jcqkPart2Seg3MapItem.getJcqkPart2Seg3Inner1List()) {
                int jcqkLevel3NumSum = jcqkPart2Seg3Inner1MapItem.getJcqkPart2Seg3Inner2List()
                        .stream()
                        .mapToInt(jcqkPart2Seg3Inner2Map::getJcqkLevel3Num)
                        .sum();
                int jcqkLevel4NumSum = jcqkPart2Seg3Inner1MapItem.getJcqkPart2Seg3Inner2List()
                        .stream()
                        .mapToInt(jcqkPart2Seg3Inner2Map::getJcqkLevel4Num)
                        .sum();
                jcqkPart2Seg3Inner1MapItem.setJcqkLevel3NumSum(jcqkLevel3NumSum);
                jcqkPart2Seg3Inner1MapItem.setJcqkLevel4NumSum(jcqkLevel4NumSum);
            }
        }
        dataMap.setJcqkPart2Seg3List(jcqkPart2Seg3MapList);

        //第一部分 ----- 二、评估结果 ----- （四）隐患分布表
        EquipRiskNumVO equipRiskNumSum = machineinfoMapper.getEquipRiskNumSum(checkId, projectId);
        BeanUtil.copyProperties(equipRiskNumSum, dataMap, CopyOptions.create().setIgnoreNullValue(true));
        //BeanUtils.copyProperties(equipRiskNumSum,dataMap);
        //计算百分比和隐患合计数量
        if (equipRiskNumSum != null) {
            int yhfbNumSum = equipRiskNumSum.getYhfb0Num() + equipRiskNumSum.getYhfb1Num() + equipRiskNumSum.getYhfb2Num() + equipRiskNumSum.getYhfb3Num() + equipRiskNumSum.getYhfb4Num();
            dataMap.setYhfbNumSum(yhfbNumSum);
            dataMap.setYhfb0Percent(calculatePercent(equipRiskNumSum.getYhfb0Num(), yhfbNumSum));
            dataMap.setYhfb1Percent(calculatePercent(equipRiskNumSum.getYhfb1Num(), yhfbNumSum));
            dataMap.setYhfb2Percent(calculatePercent(equipRiskNumSum.getYhfb2Num(), yhfbNumSum));
            dataMap.setYhfb3Percent(calculatePercent(equipRiskNumSum.getYhfb3Num(), yhfbNumSum));
            dataMap.setYhfb4Percent(calculatePercent(equipRiskNumSum.getYhfb4Num(), yhfbNumSum));
        }

        //第一部分 ----- 三、问题汇总表
        List<wthzPart3Map> wthzPart3MapList = machineinfoMapper.getEquipProblemInfo(checkId, projectId);
        dataMap.setWthzPart3List(wthzPart3MapList);

        //第一部分 ----- 四、安全情况及改进建议
        List<glgjPart4Map> glgjPart4MapList = machineinfoMapper.getProblemSummaryInfo(checkId, projectId);

        //去重
        List<glgjPart4Map> glgjPart4MapListDistinct = glgjPart4MapList.stream().distinct().collect(Collectors.toList());

        //处理结果展示形式，相同设备合并改进建议
        Map<String, String> glgjMap = new HashMap<>();
        for (int i = 0; i < glgjPart4MapListDistinct.size(); i++) {
            glgjPart4Map glgjPart4MapItem = glgjPart4MapListDistinct.get(i);
            if (glgjMap.get(glgjPart4MapItem.getGlgjType()) != null) {
                if (glgjPart4MapItem.getGlgjSuggestion() != null && glgjPart4MapItem.getGlgjSuggestion() != "null") {
                    glgjMap.put(glgjPart4MapItem.getGlgjType(), glgjMap.get(glgjPart4MapItem.getGlgjType()) + "  \r  " + glgjPart4MapItem.getGlgjSuggestion());
                }
            } else {
                glgjMap.put(glgjPart4MapItem.getGlgjType(), "    " + glgjPart4MapItem.getGlgjSuggestion());
            }
        }
        List<glgjPart4Map> newglgjPart4MapList = new LinkedList<>();
        int index = 1;
        for (String key : glgjMap.keySet()) {
            String summary = StringUtils.isBlank(glgjMap.get(key)) ? "    暂无小结" : glgjMap.get(key);
            glgjPart4Map tmp = new glgjPart4Map(index, key, summary);
            newglgjPart4MapList.add(tmp);
            index++;
        }

        dataMap.setGlgjPart4List(newglgjPart4MapList);

        //第二部分 各分项工程检查情况
        List<section2Map> section2MapList = machineinfoMapper.getEquipCheckResultInfo(checkId, projectId);
        //处理序号和图片地址
        for (section2Map section2MapItem : section2MapList) {
            for (int i = 0; i < section2MapItem.getSection2Inner1List().size(); i++) {
                section2Inner1Map section2Inner1MapItem = section2MapItem.getSection2Inner1List().get(i);
                //序号
                section2Inner1MapItem.setSection2Number(i + 1);
                //图片
                List<String> section2ImageMapList = new LinkedList<>();
                JSONArray section2picNameArray = JSONArray.parseArray(section2Inner1MapItem.getSection2PicName());
                if (section2picNameArray == null || section2picNameArray.size() == 0) {
                    //todo 报告本地测试
                    //String s = MDoc.getImageStr("D:\\Work\\LabWork\\YiRui\\文档\\Test\\Pic\\noPic.png");
                    String s = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                    section2ImageMapList.add(s);
                } else {
                    for (int j = 0; j < section2picNameArray.size(); j++) {
                        //todo 报告本地测试
                        //String s = MDoc.getImageStr("D:\\Work\\LabWork\\YiRui\\文档\\Test\\Pic\\noPic.png");
                        String s = MDoc.getImageStr(section2Inner1MapItem.getSection2PicPath() + section2picNameArray.getString(j));
                        section2ImageMapList.add(s);
                    }
                }
                section2Inner1MapItem.setSection2ImageList(section2ImageMapList);
            }
        }
        dataMap.setSection2List(section2MapList);

        //生成报告
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyyMMddhhmmss");
        String fileNameTime = dateTimeFormatter.format(LocalDateTime.now());
        String reportName = projectInfo.getProjectName().replace('#', '号') + "房建设备专项评估报告" + fileNameTime;
        String ftlName = "houseEquipAssessReport";

        BeanMap beanMap = new BeanMap(dataMap);

        return generateReport(beanMap, reportName, ftlName);

    }

    //根据分项权重和权重和算出实际权重，并输出正确的格式
    private String calculatePercent(Integer singleWeight, Integer totalWeight) {

        //要用float
        float weight = (float) 100 * singleWeight / totalWeight;
        DecimalFormat decimalFormat = new DecimalFormat("0.00");
        String res = decimalFormat.format(weight);

        return res + "%";
    }

    //根据数据结果和文件名称生成报告，返回报告地址
    private String generateReport(Map dataMap, String reportName, String ftlName) {
        MDoc mdoc = new MDoc();
        String path = FileUtil.getServerFolderPath();
        File f1 = new File(path, "doc");
        if (!f1.exists()) {
            f1.mkdirs();
        }

        //报告本地测试使用
        /*String localReportPath = "E:\\tencent_File\\1296928795\\FileRecv\\yirui\\";
        try {
            mdoc.createDoc(dataMap, localReportPath + reportName + ".doc", "ftl\\"+ ftlName +".ftl");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        MDoc.docToDocx(localReportPath + reportName + ".doc", localReportPath + reportName + ".doc");
        String result = localReportPath + reportName + ".doc";*/

        //报告在服务器使用
        String tomcatDocPath = "D:\\whutServer\\apache-tomcat-8.5.41\\webapps\\ROOT\\doc\\";
        try {
            mdoc.createDoc(dataMap, path + "\\doc\\" + reportName + ".doc", "ftl\\" + ftlName + ".ftl");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        //MDoc.docToDocx(tomcatDocPath + reportName + ".doc", tomcatDocPath + reportName + ".doc");
        String result = urlProperties.getAddress() + "/doc/" + reportName + ".doc";

        return result;
    }


    private int calculateAllFourthProblem(int checkId, JSONArray secondIdInfoArray,boolean isNew) {
        int allFourthProblem = 0;
        int temp = 0;
        for (int i = 0; i < secondIdInfoArray.size(); i++) {
            int secondId = secondIdInfoArray.getIntValue(i);
            temp = isNew?newProblemCollectDetailMapper.countProblemBySecondId(checkId, secondId):
                problemCollectDetailMapper.countProblemBySecondId(checkId, secondId);
            allFourthProblem += temp;
        }
        return allFourthProblem;
    }

    private double calculateAllWeight4Func(int checkId, JSONObject part2InnerObject, Integer taskId,boolean isNew) {
        double allweight4 = 0;
        List<ProblemCollectDetail> countFourthWeight = isNew?newProblemCollectDetailMapper.getAllFourthInfoMXTQ(checkId, part2InnerObject.getIntValue("thirdId")):
                problemCollectDetailMapper.getAllFourthInfoMXTQ(checkId, part2InnerObject.getIntValue("thirdId"));
        for (int v = 0; v < countFourthWeight.size(); v++) {
            double Tweight4 = 0;
            int fourthId = countFourthWeight.get(v).getFourthId();
            //更改取权重的表
            String newWeight4 = editableweightpsMapper.getWeightByNumber(fourthId, taskId);
            if (StringUtils.isNotBlank(newWeight4)) {
                Tweight4 = pointsCalculate.getPercentInstance(newWeight4);
            } else {
                String trueweight4 = isNew ?newprefixsystemMapper.getWeight3ByThirdId(fourthId):
                        prefixsystemMapper.getWeight3ByThirdId(fourthId);
                Tweight4 = pointsCalculate.getPercentInstance(trueweight4);
            }
            allweight4 += Tweight4;
        }
        return allweight4;
    }

    private String getCheckItemPointAndUpdateAllPointSave(int checkId, int part2FourthId, int projectId, double checkItemPoint, DecimalFormat df) {
        List<ProblemCollectDetail> checkItemCalcuList = problemCollectDetailMapper.getAllFourthInfo(checkId, part2FourthId);
        String maxFourthRiskPoint = pointsCalculate.getMaxRiskPoint(checkItemCalcuList);
        int maxFourthRiskPointNum = problemCollectDetailMapper.getRiskPointCount(checkId, part2FourthId, maxFourthRiskPoint);
        double limitFourhPoint = Double.parseDouble((pointlimitMapper.getLimitPointByInfo(String.valueOf(maxFourthRiskPointNum), maxFourthRiskPoint)) == null ? "100" : pointlimitMapper.getLimitPointByInfo(String.valueOf(maxFourthRiskPointNum), maxFourthRiskPoint));
        if (checkItemPoint > limitFourhPoint) {
            checkItemPoint = limitFourhPoint;
        }
        String s = df.format(checkItemPoint);
        int allPointSaveFourthPointCount = allpointsaveMapper.getAllPointCountByCheckId(checkId, part2FourthId);
        if (allPointSaveFourthPointCount != 0) {
            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
            Date date1 = new Date(System.currentTimeMillis());
            String lastEditTime = formatter.format(date1);
            allpointsaveMapper.updateAllPoint(checkId, s, part2FourthId, lastEditTime);
        } else {
            Allpointsave allpointsave = new Allpointsave();
            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
            Date date1 = new Date(System.currentTimeMillis());
            allpointsave.setNewCreateTime(formatter.format(date1));
            allpointsave.setLastEditTime(formatter.format(date1));
            allpointsave.setProjectId(projectId);
            allpointsave.setCheckId(checkId);
            allpointsave.setNumber(part2FourthId);
            allpointsave.setPoint(s);
            allpointsaveMapper.insert(allpointsave);
        }
        return s;
    }

    private double calculateNoProblemPointFunc(int checkId, JSONObject part2InnerObject) {
        double noProblemPoint = 0;
        List<Object> noProblemSixthIdList = uncheckeditemsMapper.getNoProblemSixthId(checkId, part2InnerObject.getIntValue("fourthId"));
        String noProblemSixthIdInfo = JSON.toJSONString(noProblemSixthIdList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        JSONArray noProblemSixthArray = JSONArray.parseArray(noProblemSixthIdInfo);
        for (int m = 0; m < noProblemSixthArray.size(); m++) {
            int noProblemSixthId = noProblemSixthArray.getIntValue(m);
            double noProblem = Double.parseDouble(prefixsystemMapper.getPoint4ByPoint4Id(noProblemSixthId));
            noProblemPoint += noProblem;
        }
        return noProblemPoint;
    }

    private String getPart2InnerListweight4(int checkId, int part2ThirdId, double weight3, double weight4, double allweight4) {
        //int countFourthId=prefixsystemMapper.getCountFourth(part2ThirdId);
        List<Object> fourthCountList = problemCollectDetailMapper.getFourthCountList(checkId, part2ThirdId);
        String fourthCountInfo = JSON.toJSONString(fourthCountList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        JSONArray fourthCountInfoArray = JSONArray.parseArray(fourthCountInfo);
        int countFourthId = fourthCountInfoArray.size();
        return pointsCalculate.double2ToPercent(weight3, allweight4 / weight4);
    }

    private List<Double> calculatePoint6Func(JSONArray sixthPointsArray, int checkId,boolean isNew) {
        double calculatePoint66 = 0;
        double calculatePoint6 = 0;
        double calculateTruePoint = 0;
        for (int y = 0; y < sixthPointsArray.size(); y++) {
            JSONObject sixPointObject = sixthPointsArray.getJSONObject(y);
            int deductSixthId = sixPointObject.getIntValue("sixthId");
            System.out.println("sixId:" + deductSixthId);
            float deductPointsSumFloat = isNew?newProblemCollectDetailMapper.getdeductSum(checkId, deductSixthId):problemCollectDetailMapper.getdeductSum(checkId,deductSixthId);
            double deductPointsSum = Double.valueOf(String.valueOf(deductPointsSumFloat));
            double truePoint = Double.parseDouble(sixPointObject.getString("point6"));
            System.out.println("各类point:" + deductPointsSum + " " + truePoint);
            if (truePoint <= deductPointsSum) {
                calculatePoint66 = 0;
            } else {
                calculatePoint66 = truePoint - deductPointsSum;
            }
            calculateTruePoint += truePoint;  //体系分数
            calculatePoint6 += calculatePoint66;  //得分总和
        }
        List<Double> calculatePointList = new ArrayList<>();
        calculatePointList.add(calculateTruePoint);
        calculatePointList.add(calculatePoint6);
        System.out.println("计算point6:" + calculatePointList);
        return calculatePointList;
    }

    /**
     * @author： wenyihan
     * @description：设备报告
     * @date： 20:22 2020/11/21
     * @param： [checkId, projectId]
     * @return： java.lang.String
     */
    @Override
    public String equipReport(int checkId, int projectId) {
        //报告最终dataMap，存储所有报告所需数据
        ReportFinalMap dataMap = new ReportFinalMap();

        //生成时间
        DateTimeFormatter dateTimeFormatterYear = DateTimeFormatter.ofPattern("yyyy");
        String year = dateTimeFormatterYear.format(LocalDate.now());
        dataMap.setYear(year);
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日");
        String reportDate = dateTimeFormatter.format(LocalDate.now());
        dataMap.setReportDate(reportDate);

        //第一部分 --- 一、工程概况
        List<ContractTaskProject> projectBasicInfo = contracttaskprojectMapper.selectAllByCheckId(projectId);
        for (ContractTaskProject ctp : projectBasicInfo) {
            dataMap.setArea(ctp.getArea());
            dataMap.setProjectName(ctp.getProjectName());
            dataMap.setJsUnit(ctp.getJsUnit());
            dataMap.setJlUnit(ctp.getJlUnit());
            dataMap.setSgUnit(ctp.getSgUnit());
            dataMap.setProgress(ctp.getProgress());
        }
        List<MachineInfo> equipInfo = machineinfoMapper.getMachineInfoByProjectId(projectId);
        List<EquipInfoListMap> equipInfoList = new ArrayList<>();
        for (MachineInfo mi : equipInfo) {
            EquipInfoListMap equipInfoMap = new EquipInfoListMap();
            equipInfoMap.setEquipModel(mi.getEquipModel());
            Integer machineTypeNum = mi.getMachineType();
            String machineType = "无";
            if (configIsNull(machineTypeNum)) {
                machineType = newprefixsystemMapper.getName4ByName4Id(machineTypeNum);
            }
            equipInfoMap.setMachineType(machineType);
            equipInfoMap.setEquipNum(mi.getEquipNum());
            equipInfoMap.setDetectionUnit(mi.getDetectionUnit());
            equipInfoMap.setInstallRemoveUnit(mi.getInstallRemoveUnit());
            equipInfoList.add(equipInfoMap);
        }
        dataMap.setEquipInfoList(equipInfoList);

        //第一部分 --- 二、评估结果
        List<EvaluatieResultListMap> evaluatieResultList = new ArrayList<>();
        for (MachineInfo mi : equipInfo) {
            //检查结果意见判断标志
            boolean flag = true;

            EvaluatieResultListMap evaluatieResultMap = new EvaluatieResultListMap();

            //第四级id
            Integer machineTypeNum = mi.getMachineType();
            String machineType = "无";
            if (configIsNull(machineTypeNum)) {
                machineType = newprefixsystemMapper.getName4ByName4Id(machineTypeNum);
            }
            evaluatieResultMap.setMachineType(machineType);
            evaluatieResultMap.setEquipNum(mi.getEquipNum());

            //获取所有第五级id
            List<Integer> fifthIdList = newprefixsystemMapper.getFifthId(machineTypeNum);
            List<FifthListVO> allFifthList = newproblemdescriptionMapper.getAllProblemDesAndOthers(fifthIdList);
            List<GradeFifthListMap> gradeFifthList = new ArrayList<>();
            for (FifthListVO fifthObj : allFifthList) {
                GradeFifthListMap gradeFifthMap = new GradeFifthListMap();
                String pName5 = newprefixsystemMapper.getName4ByName4Id(fifthObj.getFifthId());
                gradeFifthMap.setpName5(pName5);
                //有问题第六级list
                List<SixthListVO> sixthList = fifthObj.getSixthList();
                List<GradeSixthListMap> gradeSixthList = new ArrayList<>();
                int index = 1;

                for (SixthListVO sixthObj : sixthList) {
                    GradeSixthListMap gradeSixthMap = new GradeSixthListMap();
                    gradeSixthMap.setIndex(index);
                    gradeSixthMap.setpName5(pName5);
                    gradeSixthMap.setpName6(sixthObj.getpName6());

                    Double point6 = 0.0d;
                    //问题描述list
                    List<AllProblemDescriptionListVO> problemDesList = sixthObj.getProblemDescriptionList();
                    List<ProblemDescriptionListMap> problemDescriptionListFromPD = new ArrayList<>();
                    int indexProblemDes = 1;
                    for (AllProblemDescriptionListVO pdObj : problemDesList) {
                        ProblemDescriptionListMap problemDescriptionMap = new ProblemDescriptionListMap();
                        point6 = Double.parseDouble(pdObj.getPoint());
                        String deductPoint = pdObj.getDeductPoint();
                        String deductPointRange = deductPointRange(deductPoint);
                        problemDescriptionMap.setProblemDes(indexProblemDes + ". " + pdObj.getProblemDescription() + ",扣" + deductPointRange + "分；");
                        problemDescriptionListFromPD.add(problemDescriptionMap);
                        indexProblemDes++;
                    }
                    gradeSixthMap.setProblemDescriptionList(problemDescriptionListFromPD);


                    gradeSixthMap.setPoint6(point6);
                    gradeSixthMap.setProblemDescriptionList(problemDescriptionListFromPD);

                    //获取第六级id
                    Integer sixthId = sixthObj.getSixthId();

                    //有问题第六级list
                    List<ProblemCollectDetail> sixthProblemList = newProblemCollectDetailMapper.getProblemDescriptionBySixthId(checkId, sixthId);
                    Double deductPoint6 = 0.0d;
                    String problemItem = "";
                    for (ProblemCollectDetail sixthProblemObj : sixthProblemList) {
                        //扣除分数环获取
                        deductPoint6 += Double.parseDouble(sixthProblemObj.getReducePoint());
                        //有问题项循环获取
                        problemItem += "有问题项：" + sixthProblemObj.getProblemDescription() + ",扣" + sixthProblemObj.getReducePoint() + "分；";
                    }
                    gradeSixthMap.setProblemItem(problemItem);
                    gradeSixthMap.setDeductPoint6(deductPoint6);
                    gradeSixthMap.setActuralPoint6((point6 - deductPoint6)>=0?(point6 - deductPoint6):0);

                    gradeSixthList.add(gradeSixthMap);
                    index++;
                }
                gradeFifthMap.setGradeSixthList(gradeSixthList);
                Double point5 = gradeSixthList.stream()
                        .mapToDouble(GradeSixthListMap::getPoint6)
                        .sum();
                //检查结果意见判断---保证项目小计分不足40分时，评定结果为不合格。
                if (pName5.equals("保证项目") && point5 < 40) {
                    flag = false;
                }
                gradeFifthMap.setPoint5(point5);
                Double deductPoint5 = gradeSixthList.stream()
                        .mapToDouble(GradeSixthListMap::getDeductPoint6)
                        .sum();
                //检查结果意见判断---保证项目中任意一项不得分时，评定结果为不合格。
                if (pName5.equals("保证项目") && deductPoint5 != 0.0d) {
                    flag = false;
                }
                gradeFifthMap.setDeductPoint5(deductPoint5);
                gradeFifthMap.setActuralPoint5(point5 - deductPoint5);
                gradeFifthList.add(gradeFifthMap);
            }
            evaluatieResultMap.setGradeFifthList(gradeFifthList);
            Double point = gradeFifthList.stream()
                    .mapToDouble(GradeFifthListMap::getPoint5)
                    .sum();
            //检查结果意见判断---检查项目总分不足70分，评定结果为不合格。
            if (point < 70) {
                flag = false;
            }
            evaluatieResultMap.setPoint(point);
            Double acturalPoint = gradeFifthList.stream()
                    .mapToDouble(GradeFifthListMap::getActuralPoint5)
                    .sum();
            evaluatieResultMap.setDeservePoint(point);
            evaluatieResultMap.setActuralPoint(acturalPoint);
            evaluatieResultMap.setFinalPoint(acturalPoint / point * 100);
            evaluatieResultMap.setDeductPoint(point - acturalPoint);
            if (flag) {
                evaluatieResultMap.setCheckSuggestion("合格");
            } else {
                evaluatieResultMap.setCheckSuggestion("不合格");
            }

            evaluatieResultList.add(evaluatieResultMap);
        }
        dataMap.setEvaluatieResultList(evaluatieResultList);

        //第一部分 --- 三、存在问题描述
        List<SecurityProblemListMap> securityProblemList = new ArrayList<>();
        List<EquipExistProblemDesVO> equipExistProblemDesList = newProblemCollectDetailMapper.getEquipExistProblemDesList(checkId, projectId);
        for (EquipExistProblemDesVO obj : equipExistProblemDesList) {
            SecurityProblemListMap securityProblemMap = new SecurityProblemListMap();
            Integer machineTypeNum = obj.getMachineType();
            String machineType = "无";
            if (configIsNull(machineTypeNum)) {
                machineType = newprefixsystemMapper.getName4ByName4Id(machineTypeNum);
            }
            securityProblemMap.setMachineType(machineType);
            securityProblemMap.setEquipNum(obj.getEquipNum());
            securityProblemMap.setNormsProvison(obj.getNormsProvison());
            securityProblemMap.setRiskPoint(obj.getRiskPoint());
            System.out.println(obj.getRemark() + "asdjjjj");
            if (!configIsNull(obj.getRemark())) {
                securityProblemMap.setRemark(obj.getProblemDescription());
            } else {
                securityProblemMap.setRemark(obj.getRemark());
            }
            securityProblemList.add(securityProblemMap);
        }
        dataMap.setSecurityProblemList(securityProblemList);

        //第二部分
        List<CheckFourthListMap> checkFourthList = new ArrayList<>();
        List<CheckSuggestionVO> checkSuggestionList = newProblemCollectDetailMapper.getCheckSuggestionList(checkId, projectId);
        for (CheckSuggestionVO checkObj : checkSuggestionList) {
            CheckFourthListMap checkFourthMap = new CheckFourthListMap();
            checkFourthMap.setEquipNum(checkObj.getEquipNum());
            Integer machineTypeNum = checkObj.getMachineType();
            String machineType = "无";
            if (configIsNull(machineTypeNum)) {
                machineType = newprefixsystemMapper.getName4ByName4Id(machineTypeNum);
            }
            checkFourthMap.setMachineType(machineType);
            List<CheckSixthListMap> checkSixthList = new ArrayList<>();
            List<SixthProblemSuggestionListVO> sixthProblemSuggestionList = checkObj.getSixthProblemSuggestionList();
            for (SixthProblemSuggestionListVO sixthObj : sixthProblemSuggestionList) {
                CheckSixthListMap checkSixthMap = new CheckSixthListMap();
                checkSixthMap.setpName5(sixthObj.getpName5());
                checkSixthMap.setpName6(checkObj.getpName6());
                checkSixthMap.setCheckPart(sixthObj.getCheckPart());
                checkSixthMap.setNormsProvison(sixthObj.getNormsProvison());
                checkSixthMap.setProblemQua(sixthObj.getProblemQua());
                if (!configIsNull(sixthObj.getRemark())) {
                    checkSixthMap.setRemark(sixthObj.getProblemDescription());
                } else {
                    checkSixthMap.setRemark(sixthObj.getRemark());
                }
                checkSixthMap.setRiskPoint(sixthObj.getRiskPoint());
                checkSixthMap.setSuggestion(sixthObj.getSuggestion());

                //处理图片
                checkSixthMap.setPicName(sixthObj.getPicName());
                checkSixthMap.setPicPath(sixthObj.getPicPath());
                List<String> picList = new ArrayList<>();
                JSONArray picNameArray = JSONArray.parseArray(checkSixthMap.getPicName());
                if (picNameArray == null || picNameArray.size() == 0) {
                    //报告本地测试
                    String s="";
                    if ("prod".equals(profiles.getActives())) {
                        s = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                    }
                    picList.add(s);
                } else {
                    for (int j = 0; j < picNameArray.size(); j++) {
                        String s = MDoc.getImageStr(checkSixthMap.getPicPath() + picNameArray.getString(j));
                        picList.add(s);
                    }
                }
                checkSixthMap.setPicList(picList);
                checkSixthList.add(checkSixthMap);
            }
            checkFourthMap.setCheckSixthList(checkSixthList);
            checkFourthList.add(checkFourthMap);
        }
        dataMap.setCheckFourthList(checkFourthList);

        //生成报告
        DateTimeFormatter dateTime = DateTimeFormatter.ofPattern("yyyyMMddhhmmss");
        String fileNameTime = dateTime.format(LocalDateTime.now());
        String reportName = dataMap.getProjectName() + "第三方评估报告" + fileNameTime;
        String ftlName = "thirdPartyEquipReport";


        BeanMap beanMap = new BeanMap(dataMap);

        return generateReport(beanMap, reportName, ftlName);
    }

    /**
     * @author： wenyihan
     * @description：扣分范围
     * @date： 1:06 2020/11/24
     * @param： [deductPoint]
     * @return： java.lang.String
     */
    public String deductPointRange(String deductPoint) {
        List<String> list = Arrays.asList(deductPoint.split(";"));
        List<Integer> listInteger = list.stream()
                .map(Integer::parseInt)
                .collect(Collectors.toList());
        if (listInteger.size() == 1) {
            return deductPoint;
        } else {
            List<Integer> sortedList = listInteger.stream()
                    .sorted()
                    .collect(Collectors.toList());
            if (sortedList.get(0).equals(sortedList.get(sortedList.size() - 1))) {
                return sortedList.get(0) + "";
            } else {
                String deductPointRange = sortedList.get(0) + "~" + sortedList.get(list.size() - 1);
                return deductPointRange;
            }
        }
    }

    /**
     * @author： wenyihan
     * @description：判断值是否为空
     * @date： 15:21 2020/11/22
     * @param： [t]
     * @return： boolean
     */
    public <T> boolean configIsNull(T t) {
        if (t != null) {
            return true;
        }
        return false;
    }

    /**
     * @author： wenyihan
     * @description：综合巡查报告单
     * @date： 18:21 2020/11/28
     * @param： [checkId, projectId]
     * @return： java.lang.String
     */
    @Override
    public String comperhensiveInspectionReport(int checkId, int projectId) {
        ResultDataMap dataMap = new ResultDataMap("", "", "", "", new ArrayList<>(), new ArrayList<>(), new ArrayList<>());

        //第一部分 -- 表格抬头
        PartOneHeadVO partOneObj = contracttaskprojectMapper.getComInsReportPartOne(projectId, checkId);
        dataMap.setJlUnit(partOneObj.getJlUnit());
        dataMap.setProjectName(partOneObj.getProjectName());
        dataMap.setSgUnit(partOneObj.getSgUnit());
        //处理检查日期格式
        String[] checkTime = partOneObj.getCheckTime().split("-");
        dataMap.setCheckTime(checkTime[0] + "年" + checkTime[1] + "月" + checkTime[2] + "日");

        //将除表头外所需的所有数据取出
        List<ProblemFirstListVO> problemFirstList = problemCollectDetailMapper.getProblemFirstList(checkId, projectId);

        //文明施工list
        List<WMSGListMap> wmsgList = new ArrayList<>();
        //除文明施工外list
        List<ExceptWMSGListMap> exceptWMSGList = new ArrayList<>();
        //具体问题展示--带图片 list
        List<ProblemListMap> problemList = new ArrayList<>();

        for (ProblemFirstListVO firstObj : problemFirstList) {
            //修改pName1
            String pName1 = firstObj.getpName1();
            if (firstObj.getpName1().equals("安全检查")) {
                pName1 = "安全文明问题";
            } else if (firstObj.getpName1().equals("质量检查")) {
                pName1 = "工程质量问题";
            }

            /***
             * @description：第一部分
             */
            //除文明施工之外的检查
            ExceptWMSGListMap exceptWMSGMap = new ExceptWMSGListMap();

            //pName1
            exceptWMSGMap.setpName1(pName1);

            List<ProblemFourthListVO> fourthList = firstObj.getProblemFourthList();
            List<ProblemFourthListVO> exceptWMSG4List = fourthList.stream()
                    .filter(obj -> {
                        while (!obj.getpName4().equals("文明施工")) {
                            return true;
                        }
                        return false;
                    })
                    .collect(Collectors.toList());
            List<ExceptWMSGFourthListMap> exceptWMSGFourthList = new ArrayList<>();

            int index1_4 = 1;
            //pName4
            for (ProblemFourthListVO exceptWMSG4 : exceptWMSG4List) {
                ExceptWMSGFourthListMap exceptWMSGFourthMap = new ExceptWMSGFourthListMap();
                exceptWMSGFourthMap.setIndex(index1_4);
                exceptWMSGFourthMap.setpName4(exceptWMSG4.getpName4());
                List<ProblemLastListVO> problemLastList = exceptWMSG4.getProblemLastList();
                List<ExceptWMSGLastListMap> exceptWMSGLastList = new ArrayList<>();

                //last -- pd,checkPart
                int index = 1;
                for (ProblemLastListVO lastObj : problemLastList) {
                    ExceptWMSGLastListMap exceptWMSGLastMap = new ExceptWMSGLastListMap();
                    exceptWMSGLastMap.setIndex(index);
                    exceptWMSGLastMap.setCheckPart(lastObj.getCheckPart());
                    if (configIsNull(lastObj.getRemark())) {
                        exceptWMSGLastMap.setRemark(lastObj.getRemark());
                    } else {
                        exceptWMSGLastMap.setRemark(lastObj.getProblemDescription());
                    }
                    exceptWMSGLastList.add(exceptWMSGLastMap);
                    ++index;
                }
                exceptWMSGFourthMap.setExceptWMSGLastList(exceptWMSGLastList);
                exceptWMSGFourthList.add(exceptWMSGFourthMap);
                index1_4++;
            }
            exceptWMSGMap.setExceptWMSGFourthList(exceptWMSGFourthList);
            exceptWMSGList.add(exceptWMSGMap);

            //将文明施工单独提出来
            List<ProblemFourthListVO> filterWMSGList = fourthList.stream()
                    .filter(obj -> obj.getpName4().equals("文明施工"))
                    .collect(Collectors.toList());
            //文明施工
            for (ProblemFourthListVO wmsg : filterWMSGList) {
                List<ProblemLastListVO> problemLastList = wmsg.getProblemLastList();
                int index = 1;
                for (ProblemLastListVO pd : problemLastList) {
                    WMSGListMap wmsgMap = new WMSGListMap();
                    wmsgMap.setIndex(index);
                    wmsgMap.setCheckPart(pd.getCheckPart());
                    if (configIsNull(pd.getRemark())) {
                        wmsgMap.setRemark(pd.getRemark());
                    } else {
                        wmsgMap.setRemark(pd.getProblemDescription());
                    }
                    wmsgList.add(wmsgMap);
                    ++index;
                }
            }

            /***
             * @description：第二部分
             */
            ProblemListMap problemMap = new ProblemListMap();
            problemMap.setpName1(pName1);
            //pName4
            List<ProblemFourthListMap> problemFourthList = new ArrayList<>();
            int index2_4 = 1;
            for (ProblemFourthListVO problem4Obj : fourthList) {
                ProblemFourthListMap problemFourthMap = new ProblemFourthListMap();
                problemFourthMap.setIndex(index2_4);
                problemFourthMap.setpName4(problem4Obj.getpName4());
                List<ProblemLastListVO> lastList = problem4Obj.getProblemLastList();
                //pd、picName、picPath
                List<ProblemLastListMap> problemLastList = new ArrayList<>();
                int index = 1;
                for (ProblemLastListVO lastObj : lastList) {
                    ProblemLastListMap problemLastMap = new ProblemLastListMap();
                    problemLastMap.setIndex(index);
                    problemLastMap.setCheckPart(lastObj.getCheckPart());
                    if (configIsNull(lastObj.getRemark())) {
                        problemLastMap.setRemark(lastObj.getRemark());
                    } else {
                        problemLastMap.setRemark(lastObj.getProblemDescription());
                    }
                    //处理图片
                    problemLastMap.setPicName(lastObj.getPicName());
                    problemLastMap.setPicPath(lastObj.getPicPath());
                    List<PicListMap> picList = new ArrayList<>();

                    JSONArray picNameArray = JSONArray.parseArray(problemLastMap.getPicName());
                    if (picNameArray == null || picNameArray.size() == 0) {
                        PicListMap picMap = new PicListMap();
                        //报告本地测试
//                      String s = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\123.png");
                        String s = MDoc.getImageStr("D:\\whutServer\\generatedCharts\\noPic.png");
                        picMap.setProblemPic1(s);
                        picMap.setProblemPic2(s);
                        picList.add(picMap);
                    } else {
                        int j = 0;
                        while (j < picNameArray.size()) {
                            PicListMap picMap = new PicListMap();
                            //添加到最后一项
                            if (j == picNameArray.size() - 1) {
//                                String s1 = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\1.png");
                                String s1 = MDoc.getImageStr(problemLastMap.getPicPath() + picNameArray.getString(j));
                                picMap.setProblemPic1(s1);
                                ++j;
                            } else {
                                //报告本地测试
//                                String s1 = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\1.png");
//                                String s2 = MDoc.getImageStr("E:\\tencent_File\\1296928795\\FileRecv\\12.png");
                                String s1 = MDoc.getImageStr(problemLastMap.getPicPath() + picNameArray.getString(j));
                                String s2 = MDoc.getImageStr(problemLastMap.getPicPath() + picNameArray.getString(++j));
                                picMap.setProblemPic1(s1);
                                picMap.setProblemPic2(s2);
                                ++j;
                            }
                            picList.add(picMap);
                        }
                    }
                    problemLastMap.setPicList(picList);
                    problemLastList.add(problemLastMap);
                    index++;
                }
                problemFourthMap.setProblemDescriptionList(problemLastList);
                problemFourthList.add(problemFourthMap);
                index2_4++;
            }
            problemMap.setProblemFourthList(problemFourthList);
            problemList.add(problemMap);
        }
        dataMap.setExceptWMSGList(exceptWMSGList);
        dataMap.setWmsgList(wmsgList);
        dataMap.setProblemList(problemList);

        //生成报告
        DateTimeFormatter dateTime = DateTimeFormatter.ofPattern("yyyyMMddhhmmss");
        String fileNameTime = dateTime.format(LocalDateTime.now());
        String reportName = dataMap.getProjectName() + "综合巡查报告" + fileNameTime;
        String ftlName = "comperhensiveInspectionReport";


        BeanMap beanMap = new BeanMap(dataMap);

        return generateReport(beanMap, reportName, ftlName);
    }

    /**
     * @author wangqirui
     * @create 2021/3/2 下午 3:33
     * @desc 第三方设备评估报告
     **/
    @Override
    public String generate3rdPartyRiskReport(int projectId, int checkId) throws UnsupportedEncodingException {
        StandardChartTheme standardChartTheme = new StandardChartTheme("CN");
        //设置标题字体
        standardChartTheme.setExtraLargeFont(new Font("隶书", Font.BOLD, 20));
        //设置图例的字体
        standardChartTheme.setRegularFont(new Font("宋书", Font.PLAIN, 15));
        //设置轴向的字体
        standardChartTheme.setLargeFont(new Font("宋书", Font.PLAIN, 15));
        //应用主题样式
        DecimalFormat df = new DecimalFormat("0.00");
        int width = 718;
        int height = 468;
        ChartFactory.setChartTheme(standardChartTheme);
        Map<String, Object> dataMap = new HashMap<String, Object>();
        Date date = new Date();
        DateFormat d1 = new SimpleDateFormat("yyyyMMddhhmmss");
        DateFormat d2 = new SimpleDateFormat("yyyy");
        DateFormat d3 = new SimpleDateFormat("MM");
        DateFormat d4 = new SimpleDateFormat("dd");
        String day = d4.format(date);
        String month = d3.format(date);
        String year = d2.format(date);
        String fileName = d1.format(date);
        dataMap.put("zlWeight", "\\");
        dataMap.put("aqWeight", "\\");
        dataMap.put("glWeight", "\\");
        String zlWeight = newprefixsystemMapper.getWeight1ByName1("新质量检查");
        String aqWeight = newprefixsystemMapper.getWeight1ByName1("新安全检查");
        String glWeight = newprefixsystemMapper.getWeight1ByName1("新管理行为");

        dataMap.put("zlWeight", zlWeight);
        dataMap.put("aqWeight", aqWeight);
        dataMap.put("glWeight", glWeight);
        dataMap.put("day", day);
        dataMap.put("month", month);
        dataMap.put("year", year);
        dataMap.put("zlPoint", "\\");
        dataMap.put("glPoint", "\\");
        dataMap.put("aqPoint", "\\");
        DefaultPieDataset datasetPie = new DefaultPieDataset();
        DefaultCategoryDataset datasetBar = new DefaultCategoryDataset();
        final String Bar = "各检查分项";
        //工程概况部分，来自ctp的工程信息
        List<ContractTaskProject> projectList = contracttaskprojectMapper.selectAllByCheckId(projectId);
        String project = JSON.toJSONString(projectList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        System.out.println(project);
        JSONArray projectArray = JSONArray.parseArray(project);
        JSONObject projectObject = projectArray.getJSONObject(0);
        dataMap.put("projectName", projectObject.getString("projectName"));
        dataMap.put("projectAddress", projectObject.getString("area"));
        dataMap.put("jsUnit", projectObject.getString("jsUnit"));
        dataMap.put("jlUnit", projectObject.getString("jlUnit"));
        dataMap.put("sgUnit", projectObject.getString("sgUnit"));
        dataMap.put("projectType", projectObject.getString("projectType"));
        dataMap.put("projectPrice", projectObject.getString("projectPrice"));
        dataMap.put("dangerItem", projectObject.getString("dangerItem"));
        dataMap.put("remark", projectObject.getString("remark"));
        dataMap.put("projectDescription", projectObject.getString("projectDescription"));
        String js = projectObject.getString("jsUniter");
        String jl = projectObject.getString("jlUniter");
        String sg = projectObject.getString("manager");
        dataMap.put("jsUniter", js);
        dataMap.put("jlUniter", jl);
        dataMap.put("sgUniter", sg);
        //工程概况部分，来自设备信息表的设备信息部分
        List<MachineInfo> equipinfoList = machineinfoMapper.getequipTypeByProject(projectId);
        String equip = JSON.toJSONString(equipinfoList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        JSONArray equipArray = JSONArray.parseArray(equip);
        List<Object> equipList = new ArrayList<Object>();
        if (equipArray.size() == 0) {
            Map<String, Object> eqMap = new HashMap<String, Object>();
            eqMap.put("equipId", "\\");
            eqMap.put("equipType", "\\");
            eqMap.put("equipQua", "\\");
            eqMap.put("equipNum", "\\");
            eqMap.put("equipLeaseUnit", "\\");
            eqMap.put("equipUseUnit", "\\");
            eqMap.put("demolitionUnit", "\\");
            eqMap.put("testUnit", "\\");
            equipList.add(eqMap);
        } else {
            for (int i = 0; i < equipArray.size(); i++) {
                Map<String, Object> eqMap = new HashMap<String, Object>();
                JSONObject equipObject = equipArray.getJSONObject(i);
                eqMap.put("equipId", equipObject.getString("mKey"));
                int temp = 0;
                if (equipObject.getString("machineType")!=null) {
                    temp = Integer.parseInt(equipObject.getString("machineType"));
                    String equipType = newprefixsystemMapper.getName4ByName4Id(temp);
                    eqMap.put("equipType", equipType);
                }
                else{eqMap.put("equipType", "？？？");}
                String factoryNum = equipObject.getString("factoryNum");
                int count = 1;
                try {
                     count = Integer.parseInt(factoryNum);
                     if (count > 100) count  =1;
                } catch (Exception e) { count = 1;};
                eqMap.put("equipQua", count);
                //eqMap.put("equipQua", equipObject.getString("factoryNum"));
                eqMap.put("equipNum", equipObject.getString("equipNum"));
                eqMap.put("equipLeaseUnit", equipObject.getString("rentalUnit"));
                eqMap.put("equipUseUnit", equipObject.getString("useUnit"));
                eqMap.put("demolitionUnit", equipObject.getString("installRemoveUnit"));
                eqMap.put("testUnit", equipObject.getString("detectionUnit"));
                equipList.add(eqMap);
            }
        }
        dataMap.put("equipList", equipList);



        //第一部分，（二）分项评估结果

        List<subAssess> subAssessList = new ArrayList<>();
        String check = String.valueOf(checkId);

        List<ProblemCollectDetail> pcdList = newProblemCollectDetailMapper.getAllInfoByCheck(check);
        Set<Integer> thirdSet=new HashSet<>();
        for(ProblemCollectDetail problemCollectDetail:pcdList){
            if(!thirdSet.contains(problemCollectDetail.getThirdId())){
                thirdSet.add(problemCollectDetail.getThirdId());
            }
        }
        Double qzjPoint = 0d;
        Double sjjPoint = 0d;
        Double jsjPoint = 0d;
        Double dlPoint = 0d;
        Double part1Point = 0d;
        Integer allRiskPoint = 0;
        Integer riskPoint1 = 0 ;
        Integer riskPoint2 = 0 ;
        Integer riskPoint3 = 0 ;
        Integer riskPoint4 = 0 ;
        Double part1OverAllPoint = 0d;
        Double part1Num = 0d;
        //List<Integer> riskPointList = new ArrayList<>();
        List<Integer> tempRiskPointList = new ArrayList<>();
        List<Object> p3ProblemList = new ArrayList<>();
        List<Map<String , Object>> part1List = new ArrayList();

        for (Integer i:thirdSet) {
            Double mbPoint = 100d;
            Double oiPoint = 100d;

            List<Object> p4ProblemList = new ArrayList<>();

            List<ProblemCollectDetail> pcdInfoBy3rd = newProblemCollectDetailMapper.selectAllInfoByThirdId(checkId, i);

            List<Object> fourthIdList = newProblemCollectDetailMapper.getFourthId(checkId, pcdInfoBy3rd.get(0).getpName1(), pcdInfoBy3rd.get(0).getSecondId(), i);

            for (Object t:fourthIdList) {

                Map<String, Object> p4ProblemMap = new HashMap<>();

                List<ProblemCollectDetail> pcdInfoBy4th = newProblemCollectDetailMapper.getAllFourthInfo(checkId, Integer.parseInt(t.toString()));
                List<Map<String, Object>> p6ProblemList = new ArrayList<>();
                List<Map<String, Object>> dividiedP6ProblemList = new ArrayList<>();



                for (int j = 0; j < pcdInfoBy4th.size(); j++) {
                    Map<String, Object> p6ProblemMap = new HashMap<>();
                    p6ProblemMap.put("checkPart", pcdInfoBy4th.get(j).getCheckPart());
                    if (pcdInfoBy4th.get(j).getIsRemark().equals("N")) {
                        p6ProblemMap.put("problemDescription", pcdInfoBy4th.get(j).getProblemDescription());
                    } else if (pcdInfoBy4th.get(j).getIsRemark().equals("Y")) {
                        p6ProblemMap.put("problemDescription", pcdInfoBy4th.get(j).getRemark());
                    }
                    p6ProblemMap.put("riskPoint", pcdInfoBy4th.get(j).getRiskPoint());
                    p6ProblemList.add(p6ProblemMap);

                }
                //拆开checkpart和description,再按riskPoint逆序，checkPart正序
                dividiedP6ProblemList = EquipCheck.divideCheckpartAndDes(p6ProblemList);
                //按riskPoint逆序
                EquipCheck.sortRiskPoint(dividiedP6ProblemList);
                //按checkPart逆序,如果是数字则排数字，不是数字则排首字母
                dividiedP6ProblemList.sort((a,b)->{
                    String checkParta = (String) a.get("checkPart");
                    String checkPartb = (String) b.get("checkPart");
                    String[] checkPartas = checkParta.split("#");
                    checkParta = checkPartas[0];
                    String[] checkPartbs = checkPartb.split("#");
                    checkPartb = checkPartbs[0];
                    int flag = 0;
                    try {
                        Integer temp1 = Integer.parseInt(checkPartas[0]);
                        Integer temp2 = Integer.parseInt(checkPartbs[0]);
                        if (temp1.compareTo(temp2) > 0) {
                            flag = 1;
                        } else if (temp1.compareTo(temp2) == 0) {
                            flag = 0;
                        } else {
                            flag = -1;
                        }
                    } catch (Exception e) {
                        if (checkParta.compareTo(checkPartb) > 0) {
                            flag = 1;
                        } else if (checkParta.compareTo(checkPartb) == 0) {
                            flag = 0;
                        } else {
                            flag = -1;
                        }
                    }
                    return flag;
                });
                p6ProblemList = dividiedP6ProblemList;


                //统计riskPoint数量
                tempRiskPointList = EquipCheck.countRiskPoint(dividiedP6ProblemList);
                riskPoint1 += tempRiskPointList.get(1);
                riskPoint2 += tempRiskPointList.get(2);
                riskPoint3 += tempRiskPointList.get(3);
                riskPoint4 += tempRiskPointList.get(4);
                allRiskPoint += tempRiskPointList.get(0);

                //表里的p4Name应该叫安全问题但是没改，所以只能在这里改
                if (pcdInfoBy4th.get(0).getpName4().equals(pcdInfoBy4th.get(0).getpName3()))
                    p4ProblemMap.put("pName4", "安全问题");
                else {
                    p4ProblemMap.put("pName4", pcdInfoBy4th.get(0).getpName4());
                }
                p4ProblemMap.put("p6ProblemList", p6ProblemList);
                p4ProblemList.add(p4ProblemMap);
            }

            Map<String, Object> p3ProblemMap = new HashMap<>();
            p3ProblemMap.put("pName3", pcdInfoBy3rd.get(0).getpName3());
            p3ProblemMap.put("p4ProblemList", p4ProblemList);
            p3ProblemList.add(p3ProblemMap);

            //统计管理行为和内业资料的分数
            for (int k = 0; k < pcdInfoBy3rd.size(); k++) {
                if (Integer.parseInt(pcdInfoBy3rd.get(k).getReducePoint()) > Integer.parseInt(pcdInfoBy3rd.get(k).getPoint6())) {
                    pcdInfoBy3rd.get(k).setReducePoint(pcdInfoBy3rd.get(k).getPoint6());
                }
                //"2"是管理行为
                if (pcdInfoBy3rd.get(k).getSort4().equals("2")) {
                    mbPoint = mbPoint - Integer.parseInt(pcdInfoBy3rd.get(k).getReducePoint());
                }
                //"3"是内业资料
                if (pcdInfoBy3rd.get(k).getSort4().equals("3")) {
                    oiPoint = oiPoint - Integer.parseInt(pcdInfoBy3rd.get(k).getReducePoint());
                }
            }

            List<Map<String, Object>> equipEvaluationList1 = (List<Map<String, Object>>)
                    equipService.getEquipscoreBycheckIdEquipType(String.valueOf(checkId), String.valueOf(i));


            double allequipScore = 0;
            int risk1Num = 0;
            int risk2Num = 0;
            int risk3Num = 0;
            int risk4Num = 0;
            String riskLevel = " ";
            for (int j = 0; j < equipEvaluationList1.size(); j++) {

                allequipScore += Double.parseDouble((String.valueOf(equipEvaluationList1.get(j).get("equipScore"))));
                risk1Num += Integer.parseInt(equipEvaluationList1.get(j).get("risk1Num")+"");
                risk2Num += Integer.parseInt( equipEvaluationList1.get(j).get("risk2Num")+"");
                risk3Num += Integer.parseInt( equipEvaluationList1.get(j).get("risk3Num")+"");
                risk4Num += Integer.parseInt(equipEvaluationList1.get(j).get("risk4Num")+"");

            }
            double avgEquipScore = 0;

            if (equipEvaluationList1.size() != 0) {
                avgEquipScore = allequipScore / equipEvaluationList1.size();
            }

            if (avgEquipScore >= 90) riskLevel = "可忽略风险";
            else if (avgEquipScore >= 80 && avgEquipScore < 90) riskLevel = "可容忍风险";
            else if (avgEquipScore >= 70 && avgEquipScore < 80) riskLevel = "可接受风险";
            else if (avgEquipScore >= 60 && avgEquipScore < 70) riskLevel = "不可接受风险";
            else if (avgEquipScore < 60) riskLevel = "拒绝接受风险";

            Map<String, Object> tempLastLine = new HashMap<>();
            tempLastLine.put("equipNum", "综合评分");
            tempLastLine.put("risklevel", riskLevel);
            tempLastLine.put("equipScore", avgEquipScore);
            tempLastLine.put("risk1Num", risk1Num);
            tempLastLine.put("risk2Num", risk2Num);
            tempLastLine.put("risk3Num", risk3Num);
            tempLastLine.put("risk4Num", risk4Num);
            equipEvaluationList1.add(equipEvaluationList1.size(), tempLastLine);

            subAssess subAssessItem = new subAssess();
            subAssessItem.setpName3(pcdInfoBy3rd.get(0).getpName3());
            subAssessItem.setMbPoint(mbPoint.toString());
            subAssessItem.setSaPoint(avgEquipScore);
            subAssessItem.setOiPoint(oiPoint.toString());
            subAssessItem.setOverAllPoint((oiPoint  + mbPoint  + avgEquipScore)/3);
            subAssessItem.setEquipEvaluationList(equipEvaluationList1);
            subAssessList.add(subAssessItem);


            Map<String , Object> part1Map = new HashMap<>();
            part1Map.put("pName3",pcdInfoBy3rd.get(0).getpName3());
            part1Map.put("overAllPoint",(oiPoint  + mbPoint  + avgEquipScore)/3);
            part1OverAllPoint +=(oiPoint  + mbPoint  + avgEquipScore)/3;
            part1Map.put("num",equipEvaluationList1.size()-1);
            part1Num += equipEvaluationList1.size()-1;

            part1List.add(part1Map);

            if (pcdInfoBy3rd.get(0).getpName3().equals("塔式起重机"))
                qzjPoint = (oiPoint  + mbPoint  + avgEquipScore)/3;
            else if (pcdInfoBy3rd.get(0).getpName3().equals("施工升降机"))
                sjjPoint = (oiPoint  + mbPoint  + avgEquipScore)/3;
            else if (pcdInfoBy3rd.get(0).getpName3().equals("附着式升降脚手架"))
                jsjPoint = (oiPoint  + mbPoint  + avgEquipScore)/3;
            else if (pcdInfoBy3rd.get(0).getpName3().equals("高处作业吊篮"))
                dlPoint = (oiPoint  + mbPoint  + avgEquipScore)/3;
        }

        //part1Map
        part1Point = qzjPoint * 0.3 + sjjPoint * 0.3 + jsjPoint * 0.3 + dlPoint * 0.1;
        double overAllPart3Point = 0;

        Map<String , Object> part1Map = new HashMap<>();
        part1Map.put("pName3","总计");
        part1OverAllPoint = part1OverAllPoint/part1List.size();
        part1Map.put("overAllPoint",part1OverAllPoint);
        part1Map.put("num",part1Num);
        part1List.add(part1Map);

        dataMap.put("part1List", part1List);
        dataMap.put("qzjPoint", qzjPoint);
        dataMap.put("sjjPoint", sjjPoint);
        dataMap.put("jsjPoint", jsjPoint);
        dataMap.put("dlPoint", dlPoint);
        dataMap.put("part1Point", part1Point);
        dataMap.put("subAssessList", subAssessList);
        dataMap.put("problemList", p3ProblemList);

        List<Object> pName1Info = newProblemCollectDetailMapper.getAllName1Id(checkId);
        String name1 = JSON.toJSONString(pName1Info, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        JSONArray name1Array = JSONArray.parseArray(name1);   //firstId
        float allExtraPointFloat = newProblemCollectDetailMapper.getAllExtraPoint(checkId);
        double allExtraPoint = Double.valueOf(String.valueOf(allExtraPointFloat));
        double overAllPoint = 0;
        Integer taskId = contractchecktaskMapper.getTaskIdByCheckId(checkId);
        List<Object> part2List = new ArrayList<Object>();
        String Name1 = "";
        double allweight1 = 0;
        for (int i = 0; i < name1Array.size(); i++) {
            double Tweight1 = 0;
            String weight1 = newprefixsystemMapper.getWeight1ByName1(newprefixsystemMapper.getName4ByName4Id(name1Array.getIntValue(i)));
            Tweight1 = pointsCalculate.getPercentInstance(weight1);
            allweight1 += Tweight1;
        }
       /* for (int k = 0; k < name1Array.size(); k++) {
            Map<String, Object> part2Map = new HashMap<String, Object>();
            List<Object> part2InnerList = new ArrayList<Object>();
            String pName1 = newprefixsystemMapper.getName4ByName4Id(name1Array.getIntValue(k)); //通过firstId找到pName1
            double Tweight1 = 0;
            String weight1 = newprefixsystemMapper.getWeight1ByName1(pName1);  //获取权重
            Tweight1 = pointsCalculate.getPercentInstance(weight1);
            if (pName1.equals("新安全检查")) {
                List<ProblemCollectDetail> list = newProblemCollectDetailMapper.getAllInfoByName1(checkId, pName1);
                dataMap.put("aqLever", pointsCalculate.getMaxRiskPoint(list));
                Name1 = "安全文明";
            } else if (pName1.equals("新质量检查")) {
                List<ProblemCollectDetail> list = newProblemCollectDetailMapper.getAllInfoByName1(checkId, pName1);
                dataMap.put("zlLever", pointsCalculate.getMaxRiskPoint(list));
                Name1 = "质量隐患";
            } else if (pName1.equals("新管理行为")) {
                List<ProblemCollectDetail> list = newProblemCollectDetailMapper.getAllInfoByName1(checkId, pName1);
                dataMap.put("glLever", pointsCalculate.getMaxRiskPoint(list));
                Name1 = "管理行为";
            }
            part2Map.put("name1No", k + 1);
            part2Map.put("name1", Name1);
            List<Object> secondIdList = newProblemCollectDetailMapper.getSecondId(checkId, pName1);  //获取secondIdList
            String secondIdInfo = JSON.toJSONString(secondIdList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
            JSONArray secondIdInfoArray = JSONArray.parseArray(secondIdInfo);
            double allweight2 = 0;
            for (int p = 0; p < secondIdInfoArray.size(); p++) {
                int allsecondId = secondIdInfoArray.getIntValue(p);
                String weight2 = newprefixsystemMapper.getWeight3ByThirdId(allsecondId);
                double weight22 = pointsCalculate.getPercentInstance(weight2);
                allweight2 += weight22;
            }
            double allsecondPoint = 0;
            for (int u = 0; u < secondIdInfoArray.size(); u++) {
                int secondId = secondIdInfoArray.getIntValue(u);
                double weight222 = 0;
                String weight2 = newprefixsystemMapper.getWeight3ByThirdId(secondId); //获取第三级权重的weight
                weight222 = pointsCalculate.getPercentInstance(weight2);
                double point = 0;

                List<ProblemCollectDetail> fourthPoints = newProblemCollectDetailMapper.getFourthPoint(checkId, pName1, secondId);
                String fourthCalculateInfo = JSON.toJSONString(fourthPoints, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray fourthPointsCalculateArray = JSONArray.parseArray(fourthCalculateInfo);
                List<ProblemCollectDetail> noProblemItemList = newProblemCollectDetailMapper.getNoProblemItem(checkId, secondId);
                String noProblemCalculateInfo = JSON.toJSONString(noProblemItemList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray noProblemCalculateArray = JSONArray.parseArray(noProblemCalculateInfo);
                for (int j = 0; j < noProblemCalculateArray.size(); j++) {
                    Map<String, Object> part2InnerMap = new HashMap<String, Object>();
                    JSONObject part2InnerObject = noProblemCalculateArray.getJSONObject(j);
                    if (part2InnerObject.getString("pName4").equals("管理行为") || part2InnerObject.getString("pName4").equals("内业资料")) {

                        //part2InnerMap.put("pName4", "无问题项");
                        double allweight4 = this.calculateAllWeight4Func(checkId, part2InnerObject, taskId);
                        double weight3 = 0;
                        double weight4 = 0;
                        int part2FourthId = part2InnerObject.getIntValue("fourthId");
                        int part2ThirdId = part2InnerObject.getIntValue("thirdId");
                        weight3 = pointsCalculate.getPercentInstance(part2InnerObject.getString("weight3"));
                        weight4 = pointsCalculate.getPercentInstance(part2InnerObject.getString("weight4"));
                        String weight4Result = this.getPart2InnerListweight4(checkId, part2ThirdId, weight3, weight4, allweight4);
                        part2InnerMap.put("weight4", weight4Result);

                        List<ProblemCollectDetail> sixthPoints = newProblemCollectDetailMapper.getsixthPoints(checkId, part2FourthId);
                        String pointName6Info = JSON.toJSONString(sixthPoints, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                        JSONArray sixthPointsArray = JSONArray.parseArray(pointName6Info);
                        double calculatePoint6 = 0;
                        double calculateTruePoint = 0;
                        List<Double> calculatePointList = this.calculatePoint6Func(sixthPointsArray, checkId);
                        calculatePoint6 = calculatePointList.get(0);
                        calculateTruePoint = calculatePointList.get(1);
                        double noProblemPoint = this.calculateNoProblemPointFunc(checkId, part2InnerObject);
                        System.out.println("第六级扣过的分数总分:" + calculatePoint6 + "没有问题的总分:" + noProblemPoint + "第六级总分:" + calculateTruePoint);
                        //第4级分数 checkItemPoint
                        double checkItemPoint = (calculatePoint6 + noProblemPoint) / (calculateTruePoint + noProblemPoint) * 100;
                        String s = this.getCheckItemPointAndUpdateAllPointSave(checkId, part2FourthId, projectId, checkItemPoint, df);

                        part2InnerMap.put("checkItemPoint", s);
                        //point += checkItemPoint * weight3 / countFourthId;
                        //point += checkItemPoint * weight3 / (allweight4/weight4);
                        part2InnerList.add(part2InnerMap);
                    }
                }
                for (int j = 0; j < fourthPointsCalculateArray.size(); j++) {

                    Map<String, Object> part2InnerMap = new HashMap<String, Object>();
                    JSONObject part2InnerObject = fourthPointsCalculateArray.getJSONObject(j);
                    if (part2InnerObject.getString("pName4").equals("管理行为") || part2InnerObject.getString("pName4").equals("内业资料")) {

                        part2InnerMap.put("pName4", part2InnerObject.getString("pName4"));
                        double allweight4 = this.calculateAllWeight4Func(checkId, part2InnerObject, taskId);
                        double weight3 = 0;
                        double weight4 = 0;
                        int part2FourthId = part2InnerObject.getIntValue("fourthId");
                        int part2ThirdId = part2InnerObject.getIntValue("thirdId");
//                    weight3 = pointsCalculate.getPercentInstance(part2InnerObject.getString("weight3"));
//                    weight4 = pointsCalculate.getPercentInstance(part2InnerObject.getString("weight4"));
                        String newWeight4 = editableweightpsMapper.getWeightByNumber(part2FourthId, taskId);
                        if (StringUtils.isNotBlank(newWeight4)) {
                            weight4 = pointsCalculate.getPercentInstance(newWeight4);
                        } else {
                            weight4 = pointsCalculate.getPercentInstance(part2InnerObject.getString("weight4"));
                        }
                        String newWeight3 = editableweightpsMapper.getWeightByNumber(part2ThirdId, taskId);
                        if (StringUtils.isNotBlank(newWeight3)) {
                            weight3 = pointsCalculate.getPercentInstance(newWeight3);
                        } else {
                            weight3 = pointsCalculate.getPercentInstance(part2InnerObject.getString("weight3"));
                        }

                        String weight4Result = this.getPart2InnerListweight4(checkId, part2ThirdId, weight3, weight4, allweight4);
                        part2InnerMap.put("weight4", weight4Result);

                        List<ProblemCollectDetail> sixthPoints = newProblemCollectDetailMapper.getsixthPoints(checkId, part2FourthId);
                        String pointName6Info = JSON.toJSONString(sixthPoints, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                        JSONArray sixthPointsArray = JSONArray.parseArray(pointName6Info);
                        double calculatePoint6 = 0;
                        double calculateTruePoint = 0;
                        List<Double> calculatePointList = this.calculatePoint6Func(sixthPointsArray, checkId);
                        calculatePoint6 = calculatePointList.get(1);
                        calculateTruePoint = calculatePointList.get(0);
                        double noProblemPoint = this.calculateNoProblemPointFunc(checkId, part2InnerObject);
                        System.out.println("第六级扣过的分数总分:" + calculatePoint6 + "没有问题的总分:" + noProblemPoint + "第六级总分:" + calculateTruePoint);
                        double pName4Point = (calculatePoint6 + noProblemPoint) / (calculateTruePoint + noProblemPoint) * 100;
                        // String s = this.getCheckItemPointAndUpdateAllPointSave(checkId, part2FourthId, projectId, pName4Point, df);

                        //part2InnerMap.put("pName4Point", pName4Point);

                        point += pName4Point;
                        part2InnerList.add(part2InnerMap);
                    }
                }

            }

            part2Map.put("part2InnerList", part2InnerList);
            part2List.add(part2Map);
        }*/


        //第一部分，（三）各个专业问题的分布情况
        List<Object> pName4Info = newProblemCollectDetailMapper.getAllName4(checkId);
        //int allProblemNum = newProblemCollectDetailMapper.getAllNum(checkId);
        int allProblemNum = allRiskPoint;
        dataMap.put("allProblemNum", allProblemNum);
        String name4 = JSON.toJSONString(pName4Info, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        JSONArray name4Array = JSONArray.parseArray(name4);
        List<Object> part3List = new ArrayList<Object>();
        for (int m = 0; m < name4Array.size(); m++) {
            Map<String, Object> part3Map = new HashMap<String, Object>();
            int pName4Id = name4Array.getIntValue(m);
            String pName4 = newprefixsystemMapper.getName4ByName4Id(pName4Id);
            int name4Num = newProblemCollectDetailMapper.countName4(pName4Id, checkId);
            String percent = pointsCalculate.caculateToPercent(name4Num, allProblemNum);
            part3Map.put("No", m + 1);
            part3Map.put("name4", pName4);
            part3Map.put("problemNum", name4Num);
            part3Map.put("percent", percent);
            datasetPie.setValue(pName4 + ":" + percent, new Double(name4Num));
            datasetBar.addValue(name4Num, Bar, pName4);
            part3List.add(part3Map);
        }
        dataMap.put("part3List", part3List);

        //第一部分，三.检查问题综述

        List<Object> partProblemList = new ArrayList<Object>();
        for (int i = 0; i < name1Array.size(); i++) {
            List<Object> partProblemName1List = new ArrayList<Object>();
            Map<String, Object> partProblemMap = new HashMap<String, Object>();
            String pName1 = newprefixsystemMapper.getName4ByName4Id(name1Array.getIntValue(i));
            List<Object> problemName4List = newProblemCollectDetailMapper.getAllName4ByName1(checkId, pName1);
            String problemName4Info = JSON.toJSONString(problemName4List, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
            JSONArray problemName4Array = JSONArray.parseArray(problemName4Info);
            for (int k = 0; k < problemName4Array.size(); k++) {
                List<ProblemCollectDetail> partProblemDetailList = newProblemCollectDetailMapper.getAllFourthInfo(checkId, problemName4Array.getIntValue(k));
                String partProblemDetailInfo = JSON.toJSONString(partProblemDetailList, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray partProblemDetailArray = JSONArray.parseArray(partProblemDetailInfo);
                String problemName4 = newprefixsystemMapper.getName4ByName4Id(problemName4Array.getIntValue(k));
                for (int j = 0; j < partProblemDetailArray.size(); j++) {
                    Map<String, Object> partProblemName1Map = new HashMap<String, Object>();
                    JSONObject partProblemObject = partProblemDetailArray.getJSONObject(j);
                    String problemDescription = partProblemObject.getString("problemDescription");
                    String riskPoint = partProblemObject.getString("riskPoint");
                    if (partProblemObject.getString("isRemark").equals("N")) {
                        partProblemName1Map.put("problemDescription", problemDescription);
                    } else if (partProblemObject.getString("isRemark").equals("Y")) {
                        partProblemName1Map.put("problemDescription", partProblemObject.getString("remark"));
                    }
                    partProblemName1Map.put("riskPoint", riskPoint);
                    partProblemName1Map.put("name4", problemName4);
                    partProblemName1List.add(partProblemName1Map);
                }
            }
            System.out.println("pName1   =====" + pName1.toString());
            if (pName1.equals("新安全检查")) {
                partProblemMap.put("name1", "安全");
            } else if (pName1.equals("新质量检查")) {
                partProblemMap.put("name1", "质量");
            } else if (pName1.equals("新管理行为")) {
                partProblemMap.put("name1", "管理行为");
            } else if (pName1.equals("新设备检查")) {
                partProblemMap.put("name1", "设备检查");
            }

            dataMap.put("partProblemName1List", partProblemName1List);

        }
        int txNum = newProblemCollectDetailMapper.getAllRiskPointCountByType(checkId, "提醒");
        dataMap.put("txNum", txNum);
        dataMap.put("oneNum", riskPoint1);
        dataMap.put("twoNum", riskPoint2);
        dataMap.put("threeNum", riskPoint3);
        dataMap.put("fourNum", riskPoint4);
        String txPercent = pointsCalculate.caculateToPercent(txNum, allRiskPoint);
        String onePercent = pointsCalculate.caculateToPercent(riskPoint1, allRiskPoint);
        String twoPercent = pointsCalculate.caculateToPercent(riskPoint2, allRiskPoint);
        String threePercent = pointsCalculate.caculateToPercent(riskPoint3, allRiskPoint);
        String fourPercent = pointsCalculate.caculateToPercent(riskPoint4, allRiskPoint);
        String txAndOnePercent = pointsCalculate.caculateToPercent(txNum + riskPoint1, allRiskPoint);
        dataMap.put("txPercent", txPercent);
        dataMap.put("onePercent", onePercent);
        dataMap.put("twoPercent", twoPercent);
        dataMap.put("threePercent", threePercent);
        dataMap.put("fourPercent", fourPercent);
        DefaultPieDataset datasetRiskPie = new DefaultPieDataset();
        DefaultCategoryDataset datasetRiskBar = new DefaultCategoryDataset();
        datasetRiskPie.setValue("提醒和特征值1" + ":" + txAndOnePercent, new Double(txNum + riskPoint1));
        datasetRiskPie.setValue("特征值2" + ":" + twoPercent, new Double(riskPoint2));
        datasetRiskPie.setValue("特征值3" + ":" + threePercent, new Double(riskPoint3));
        datasetRiskPie.setValue("特征值4" + ":" + fourPercent, new Double(riskPoint4));
        final String flag1 = "提醒和特征值1";
        final String flag2 = "特征值2";
        final String flag3 = "特征值3";
        final String flag4 = "特征值4";
        final String riskBar = "特征值情况统计";
        datasetRiskBar.addValue(txNum + riskPoint1, flag1, riskBar);
        datasetRiskBar.addValue(riskPoint2, flag2, riskBar);
        datasetRiskBar.addValue(riskPoint3, flag3, riskBar);
        datasetRiskBar.addValue(riskPoint4, flag4, riskBar);
        try {
            JFreeChart chart = ChartFactory.createPieChart("隐患分布饼图", datasetRiskPie, true, true, false);
            final PiePlot plot = (PiePlot) chart.getPlot();
            plot.setStartAngle(0);
            plot.setForegroundAlpha(0.90f);
            plot.setInteriorGap(0.02);
            chart.getLegend().setVisible(false);
            plot.setSectionPaint("特征值1" + ":" + txAndOnePercent, new Color(49, 95, 232));
            plot.setSectionPaint("特征值2" + ":" + twoPercent, new Color(232, 232, 49));
            plot.setSectionPaint("特征值3" + ":" + threePercent, new Color(240, 117, 60));
            plot.setSectionPaint("特征值4" + ":" + fourPercent, new Color(232, 36, 18));
//            File pieChart = new File("D:\\PROGRAM\\YIRUI\\3rdPartyRiskReport\\png\\" + fileName + "RiskpieChart.png");
            File pieChart = new File("D:\\whutServer\\generatedCharts\\" + fileName + "RiskpieChart.png");
            ChartUtils.saveChartAsPNG(pieChart, chart, width, height);
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            JFreeChart barChart = ChartFactory.createBarChart("隐患分布直方图",
                    "",
                    "数量",
                    datasetRiskBar,
                    PlotOrientation.VERTICAL,
                    true, true, false);
            CategoryPlot plot = (CategoryPlot) barChart.getPlot();
            plot.getRenderer().setSeriesPaint(0, new Color(49, 95, 232));
            plot.getRenderer().setSeriesPaint(1, new Color(232, 232, 49));
            plot.getRenderer().setSeriesPaint(2, new Color(240, 117, 60));
            plot.getRenderer().setSeriesPaint(3, new Color(232, 36, 18));
            BarRenderer barRenderer = (BarRenderer) plot.getRenderer();
            barRenderer.setDefaultItemLabelGenerator(new StandardCategoryItemLabelGenerator());
            barRenderer.setDefaultItemLabelsVisible(true);
            barRenderer.setItemLabelAnchorOffset(-20D);
//            File barChartFile = new File("D:\\PROGRAM\\YIRUI\\3rdPartyRiskReport\\png\\" + fileName + "RiskbarChart.png");
            File barChartFile = new File("D:\\whutServer\\generatedCharts\\" + fileName + "RiskbarChart.png");

            ChartUtils.saveChartAsPNG(barChartFile, barChart, width, height);
        } catch (Exception e) {
            e.printStackTrace();
        }
//        dataMap.put("pic8", MDoc.getImageStr("D:\\PROGRAM\\YIRUI\\3rdPartyRiskReport\\png\\" + fileName + "RiskpieChart.png"));
//        dataMap.put("pic9", MDoc.getImageStr("D:\\PROGRAM\\YIRUI\\3rdPartyRiskReport\\png\\" + fileName + "RiskbarChart.png"));
                dataMap.put("pic8", MDoc.getImageStr("D:\\whutServer\\generatedCharts\\" + fileName + "RiskpieChart.png"));
                dataMap.put("pic9", MDoc.getImageStr("D:\\whutServer\\generatedCharts\\" + fileName + "RiskbarChart.png"));

        //}


        //第二部分，各部分工程检查情况
        String section2pName1 = "";
        List<Object> section2List = new ArrayList<Object>();
        for (int b = 0; b < name1Array.size(); b++) {
            Map<String, Object> section2Name1Map = new HashMap<String, Object>();
            List<Object> section2name1List = new ArrayList<Object>();
            String section2name1 = newprefixsystemMapper.getName4ByName4Id(name1Array.getIntValue(b));
            if (section2name1.equals("新安全检查")) {
                section2pName1 = "安全问题";
            } else if (section2name1.equals("新质量检查")) {
                section2pName1 = "质量问题";
            } else if (section2name1.equals("新管理行为")) {
                section2pName1 = "管理体系及管理动作";
            } else if (section2name1.equals("新设备检查")) {
                section2pName1 = "设备检查问题";
            }
            section2Name1Map.put("section2pName1", section2pName1);
            List<Object> section2Name4Info = newProblemCollectDetailMapper.getAllName4ByName1(checkId, section2name1);
            String section2Name44 = JSON.toJSONString(section2Name4Info, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
            JSONArray section2Name4Array = JSONArray.parseArray(section2Name44);
            for (int w = 0; w < section2Name4Array.size(); w++) {
                Map<String, Object> section2Name4Map = new HashMap<String, Object>();
                List<Object> section2Name4List = new ArrayList<Object>();
                int section2Name4Id = section2Name4Array.getIntValue(w);
                String section2Name4 = newprefixsystemMapper.getName4ByName4Id(section2Name4Id);
                List<ProblemCollectDetail> section2Name6Info = newProblemCollectDetailMapper.getAllName6InfoByName4(checkId, section2Name4Id, section2name1);
                String section2Name66 = JSON.toJSONString(section2Name6Info, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
                JSONArray section2Name6Array = JSONArray.parseArray(section2Name66);
                for (int c = 0; c < section2Name6Array.size(); c++) {
                    Map<String, Object> section2Name6Map = new HashMap<String, Object>();
                    List<Object> picList = new ArrayList<Object>();
                    JSONObject section2Name6Object = section2Name6Array.getJSONObject(c);
                    section2Name6Map.put("section2pName6No", c + 1);
                    section2Name6Map.put("section2pName6", section2Name6Object.getString("pName6"));
                    section2Name6Map.put("section2pName5", section2Name6Object.getString("pName5"));
                    section2Name6Map.put("section2RiskLevel", section2Name6Object.getString("riskPoint"));
                    section2Name6Map.put("section2CheckPart", section2Name6Object.getString("checkPart"));
                    section2Name6Map.put("section2ProblemNum", section2Name6Object.getString("problemQua"));
                    if (section2Name6Object.getString("isRemark").equals("N")) {
                        section2Name6Map.put("section2problemDescription", section2Name6Object.getString("problemDescription"));
                    } else if (section2Name6Object.getString("isRemark").equals("Y")) {
                        section2Name6Map.put("section2problemDescription", section2Name6Object.getString("remark"));
                    }
                    section2Name6Map.put("section2normsProvison", section2Name6Object.getString("normsProvison"));
                    section2Name6Map.put("section2suggestion", section2Name6Object.getString("suggestion"));
                    String section2picPath = section2Name6Object.getString("picPath");
                    String picName = section2Name6Object.getString("picName");
                    JSONArray ja = JSONArray.parseArray(picName);
                    if (ja.size() == 0) {
//                        String s = MDoc.getImageStr("D:\\PROGRAM\\YIRUI\\3rdPartyRiskReport\\png\\12.png");

                            String s = MDoc.getImageStr(
                                    "D:\\whutServer\\generatedCharts\\noPic.png");
                        picList.add(s);
                    } else {
                        for (int o = 0; o < ja.size(); o++) {
                            String s="";
                            if(profiles.getActives().equals("prod")){
                                s = MDoc.getImageStr(section2picPath + ja.getString(o));
                                //s="";
                            }
                            picList.add(s);
                        }
                    }
                    section2Name6Map.put("picList", picList);
                    section2Name4List.add(section2Name6Map);

                }
                section2Name4Map.put("section2pName4", section2Name4);
                section2Name4Map.put("section2Name4List", section2Name4List);
                section2name1List.add(section2Name4Map);
            }
            section2Name1Map.put("section2Name1List", section2name1List);
            section2List.add(section2Name1Map);
        }
        try {
            JFreeChart chart = ChartFactory.createPieChart("现场施工问题分布饼图", datasetPie, true, true, false);
            final PiePlot plot = (PiePlot) chart.getPlot();
            plot.setStartAngle(270);
            plot.setForegroundAlpha(0.90f);
            plot.setInteriorGap(0.02);
            chart.getLegend().setVisible(false);
//            File pieChart = new File("D:\\PROGRAM\\YIRUI\\3rdPartyRiskReport\\png\\" + fileName + "pieChart.png");
             File pieChart = new File("D:\\whutServer\\generatedCharts\\" + fileName + "pieChart.png");
            ChartUtils.saveChartAsPNG(pieChart, chart, width, height);
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            JFreeChart barChart = ChartFactory.createBarChart("现场施工问题分布直方图",
                    "",
                    "数量",
                    datasetBar,
                    PlotOrientation.VERTICAL,
                    true, true, false);
            CategoryPlot plot = (CategoryPlot) barChart.getPlot();
            plot.getRenderer().setSeriesPaint(0, new Color(5, 87, 232));
            BarRenderer barRenderer = (BarRenderer) plot.getRenderer();
            barRenderer.setDefaultItemLabelGenerator(new StandardCategoryItemLabelGenerator());
            barRenderer.setDefaultItemLabelsVisible(true);
            barRenderer.setItemLabelAnchorOffset(-20D);
            barRenderer.setMaximumBarWidth(0.2);
            CategoryAxis categoryAxis = plot.getDomainAxis();
            categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
//            File barChartFile = new File("D:\\PROGRAM\\YIRUI\\3rdPartyRiskReport\\png\\" + fileName + "barChart.png");
             File barChartFile = new File("D:\\whutServer\\generatedCharts\\" + fileName + "barChart.png");

            ChartUtils.saveChartAsPNG(barChartFile, barChart, width, height);
        } catch (Exception e) {
            e.printStackTrace();
        }
//        dataMap.put("pic6", MDoc.getImageStr("D:\\PROGRAM\\YIRUI\\3rdPartyRiskReport\\png\\" + fileName + "pieChart.png"));
//        dataMap.put("pic7", MDoc.getImageStr("D:\\PROGRAM\\YIRUI\\3rdPartyRiskReport\\png\\" + fileName + "barChart.png"));
            dataMap.put("pic6", MDoc.getImageStr("D:\\whutServer\\generatedCharts\\" + fileName + "pieChart.png"));
            dataMap.put("pic7", MDoc.getImageStr("D:\\whutServer\\generatedCharts\\" + fileName + "barChart.png"));


        dataMap.put("section2List", section2List);


        //根据dataMap生成报告
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyyMMddhhmmss");
        String fileNameTime = dateTimeFormatter.format(LocalDateTime.now());
        String reportName = HbyrStringUtils.wipeOffSymbol(String.valueOf(dataMap.get("projectName")),'#')+"第三方设备风险评估报告" + fileNameTime;
        String ftlName = "thirdPartyRiskReport";

        return ReportCommonFunc.generateReport(dataMap, reportName, ftlName);

    }
    private String getMachineTypeByNum(Integer machineType){
        if (machineType == null) {
            throw new NullPointerException("空指针异常");
        }
        return newprefixsystemMapper.getName4ByName4Id(machineType);
    }

    // yyyy-mm-dd 转为年月日
    public static String getChinaDateFromString(String str) {
        try {
            if(str==null ){
                return getChinaCurrentDate();
            }
            str = str.trim();
            int year = 0;
            int month = 0;
            int day = 0;
            if(str==null || str.equals("null") || str.equals("")){
                return getChinaCurrentDate();
            }
            else if (str.indexOf("年") > 0||str.indexOf("月") > 0||str.indexOf("日") > 0) {
                return str;
            }
            else {
                if (str.length() == 10 && (str.indexOf("-") > 0)) { //  add str.indexOf("-") > 0
                    year = Integer.parseInt(str.substring(0, 4));
                    month = Integer.parseInt(str.substring(5, 7));
                    day = Integer.parseInt(str.substring(8, 10));
                }
                else if (str.length() == 8) {
                    year = Integer.parseInt(str.substring(0, 4));
                    month = Integer.parseInt(str.substring(4, 6));
                    day = Integer.parseInt(str.substring(6, 8));
                }
                else if (str.length() == 6) {
                    year = Integer.parseInt(str.substring(0, 4));
                    month = Integer.parseInt(str.substring(4, 6));
                }
                if (day == 0)
                    str = year + "年" + month + "月";
                else
                    str = year + "年" + month + "月" + day + "日";
            }
        }
        catch (Exception e) {
            e.printStackTrace();

        }
        return str;
    }

    public static String getChinaCurrentDate() {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");

        String str_date = dateFormat.format(Calendar.getInstance().getTime());

         str_date = str_date.substring(0, 4) + "年" + str_date.substring(4, 6) + "月" +

                str_date.substring(6, 8) + "日 ";

        return str_date;

    }

    @Override
    public String equipReport(int checkId, int projectId, String checkPart, int fourthId, String ftlName) {
        Map<String, Object> dataMap = new HashMap<String, Object>();
        ContractCheckTask cct= contractchecktaskMapper.selectByPrimaryKey(checkId);
        ContractTaskProject ctp = contracttaskprojectMapper.selectByPrimaryKey(projectId);
        dataMap.put("area",ctp.getArea());
        dataMap.put("projectName",cct.getProjectName());
        dataMap.put("checkPart",checkPart);
        String time = getChinaDateFromString(cct.getFinishTime());
        dataMap.put("finishTime",time);
        MachineInfo Mi=machineinfoMapper.getAllByProjectIdAndEquipNum(projectId,checkPart);
        dataMap.put("equipModel",Mi.getEquipModel());
        if (Mi.getRegistNum() == null) {
            dataMap.put("registNum","//");
        }
        else {
            dataMap.put("registNum",Mi.getRegistNum());
        }
        if (Mi.getProductionUnit() == null) {
            dataMap.put("productionUnit","//");
        }
        else {
            dataMap.put("productionUnit",Mi.getProductionUnit());
        }
        if (Mi.getEquipRegistNum() == null) {
            dataMap.put("equipRegistNum","//");
        }
        else {
            dataMap.put("equipRegistNum",Mi.getEquipRegistNum());
        }
        if (Mi.getFactoryDate() == null) {
            dataMap.put("factoryDate","//");
        }
        else {
            dataMap.put("factoryDate",Mi.getFactoryDate());
        }
        if (Mi.getFactoryNum() == null) {
            dataMap.put("factoryNum","//");
        }
        else {
            dataMap.put("factoryNum",Mi.getFactoryNum());
        }
        if (Mi.getInstallRemoveUnit() == null) {
            dataMap.put("installRemoveUnit","//");
        }
        else {
            dataMap.put("installRemoveUnit",Mi.getInstallRemoveUnit());
        }
        if (Mi.getUseHeight() == null) {
            dataMap.put("useHeight","//");
        }
        else {
            dataMap.put("useHeight",Mi.getUseHeight()+"米");
        }
        if (Mi.getFrameHeight() == null) {
            dataMap.put("frameHeight","//");
        }
        else {
            dataMap.put("frameHeight",Mi.getFrameHeight());
        }
        if (Mi.getDetectionUnit() == null) {
            dataMap.put("detectionUnit","//");
        }
        else {
            dataMap.put("detectionUnit",Mi.getDetectionUnit());
        }
        if (Mi.getUseUnit() == null) {
            dataMap.put("useUnit","//");
        }
        else {
            dataMap.put("useUnit",Mi.getUseUnit());
        }
        if (Mi.getEquipNum() == null) {
            dataMap.put("equipNum","//");
        }
        else {
            dataMap.put("equipNum",Mi.getEquipNum());
        }
        List<ProblemCollectDetail> problemCollectDetails =newProblemCollectDetailMapper.getAllFourthInfo(checkId, fourthId);
        List<ProblemCollectDetail>  ensureList = new ArrayList<ProblemCollectDetail>();
        List<ProblemCollectDetail>  normalList = new ArrayList<ProblemCollectDetail>();
        for (ProblemCollectDetail pcd:problemCollectDetails) {
            if (pcd.getCheckPart().equals(checkPart)) {
//                if(pcd.getProblemDescription().contains("(")){
//                String Str=pcd.getProblemDescription();
//                String newStr=Str.substring(Str.indexOf("(")+1, Str.lastIndexOf(")"));
//                pcd.setProblemDescription(newStr);
//                }
                if(!pcd.getRemark().isEmpty())
                {
                    pcd.setProblemDescription(pcd.getRemark());
                }
                if (pcd.getpName5().equals("保证项目")) {
                    ensureList.add(pcd);
                }
                if (pcd.getpName5().equals("一般项目")) {
                    normalList.add(pcd);
                }
            }
        }
        for (int i = 0; i < ensureList.size(); i++) {
            ensureList.get(i).setMkey(i+1);
        }
        for (int i = 0; i < normalList.size(); i++) {
            normalList.get(i).setMkey(i+1);
        }
        dataMap.put("ensureList",ensureList);
        dataMap.put("normalList",normalList);
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyyMMddhhmmss");
        String fileNameTime = dateTimeFormatter.format(LocalDateTime.now());
        String reportName = checkPart.replace('#', '号')+"检查表("+ctp.getArea()+")" + fileNameTime;
        return ReportCommonFunc.generateReport(dataMap, reportName, ftlName);
    }
    @Override
    public String equipTowerReport(int checkId, int projectId, String checkPart, int fourthId) {
        String ftlName = "equipTower";
        return equipReport(checkId, projectId, checkPart,fourthId,ftlName);
    }
    //施工升降机检查表 物料提升机 和塔式表完全一致
    @Override
    public String constructionLifterReport(int checkId, int projectId, String checkPart, int fourthId) {
        return equipTowerReport( checkId,  projectId,  checkPart,  fourthId);
    }
    //门式起重机检查表  多一个为空的跨度，可以忽略
    @Override
    public String gantryCraneReport(int checkId, int projectId, String checkPart, int fourthId) {
        String ftlName = "gantryCrane";
        return equipReport( checkId,  projectId,  checkPart,  fourthId ,ftlName);
    }
    //流式起重机
    @Override
    public String streamingCraneReport(int checkId, int projectId, String checkPart, int fourthId) {
        String ftlName = "streamingCrane";
        return equipReport( checkId,  projectId,  checkPart,  fourthId ,ftlName);
    }
    //附着式升降脚手架
    @Override
    public String insertedLiftScaffoldReport(int checkId, int projectId, String checkPart, int fourthId) {
        String ftlName = "insertedLiftScaffold";
        return equipReport( checkId,  projectId,  checkPart,  fourthId ,ftlName);
    }
    //高处作业吊篮
    @Override
    public String highWorkHangingBasketReport(int checkId, int projectId, String checkPart, int fourthId) {
        String ftlName = "highWorkHangingBasket";
        return equipReport( checkId,  projectId,  checkPart,  fourthId ,ftlName);
    }

}
